Calendar Contest Problem 1 Sexagenary Cycle Solution

Sexagenary Cycle Solution

Historically, in China, years can be expressed with the sexagenary cycle, which is a cycle of sixty years. Each year in the cycle is named using two Chinese characters, the first one being one of the ten “heavenly stems” (天干) and the second being one of the twelve “earthly branches” (地支). Individually, the heavenly stems and earthly branches cycle, and since lcm(10,12)=60lcm⁡(10,12)=60, together they form a 60-year cycle.

The heavenly stems are, in order: 甲, 乙, 丙, 丁, 戊, 己, 庚, 辛, 壬, 癸.

The earthly branches are, in order: 子, 丑, 寅, 卯, 辰, 巳, 午, 未, 申, 酉, 戌, 亥. As an aside, each one of the earthly branches corresponds to an animal in the Chinese zodiac cycle (生肖). For example, if the earthly branch of a year is 子, then it’s the year of the rat, and if it’s 亥, then it’s the year of the pig.

The cycle starts with 甲子, 乙丑, 丙寅, …, and ends with 癸亥 after 60 years, cycling through the heavenly stems six times and the earthly stems five times. The year after 癸亥 will once again be 甲子.

For reference, the current cycle (as of 2021) started with 甲子 in 1984. The year 1985 is 乙丑 and 1986 is 丙寅. The year 2021 is 辛丑, which is the year of the ox (evident from 丑).

While this cycle is no longer used in daily life in China, it still is used for certain historical events. For example, the 1911 revolution which ended the Qing dynasty is called the 辛亥革命 (Xinhai revolution). You would like to be able to find the stem-and-branch name given a year number.

Input Specification

The first line of the input will contain the integer N (0≤N≤1000)N (0≤N≤1000), the number of lines to follow.

Every subsequent line will contain exactly one integer, the year y (−109≤y≤109)y (−109≤y≤109). Per standard convention, year 0 is 1 BCE, year -1 is 2 BCE, etc.

Output Specification

For each year given, output a line containing two Chinese characters representing the stem-and-branch name of the year as part of the sexagenary cycle. This output should be encoded as UTF-8.

Sample Input


Sample Output


Note: Please click one of our ads once we reach 20 click’s will release the solution’s. It help’s us to generate revenue and run this site

Calendar Contest Problem

  1. Sexagenary Cycle Solution
  2. Day of the Week Solution
  3. Classical Maya Solution
  4. Savvyday 29 Oatmeal 94
  5. Reign of Terror Solution
  6. Ming Dynasty Solution

Leave a Comment

error: Content is protected !!
Please Click on 1 or 2 Ads to help us run this site.