#P8738. [蓝桥杯 2020 国 C] 天干地支

[蓝桥杯 2020 国 C] 天干地支

Problem Description

Ancient China used the “Heavenly Stems and Earthly Branches” system to record the current year.

There are 10 Heavenly Stems: 甲 (jia), 乙 (yi), 丙 (bing), 丁 (ding), 戊 (wu), 己 (ji), 庚 (geng), 辛 (xin), 壬 (ren), 癸 (gui).

There are 12 Earthly Branches: 子 (zi), 丑 (chou), 寅 (yin), 卯 (mao), 辰 (chen), 巳 (si), 午 (wu), 未 (wei), 申 (shen), 酉 (you), 戌 (xu), 亥 (hai).

By concatenating a Heavenly Stem and an Earthly Branch, we get a year name in this system, for example, “jiazi”. The year 2020 is “gengzi”.

Each year, both the Heavenly Stem and the Earthly Branch move to the next one. For example, 2021 is “xinchou”.

Every 60 years, the Heavenly Stems cycle 6 times and the Earthly Branches cycle 5 times, so the combined year name repeats every 60 years. For example, 1900, 1960, and 2020 are all “gengzi”.

Given a year in the Gregorian calendar (AD), output its Heavenly Stems and Earthly Branches year name.

Input Format

One line contains a positive integer, representing the AD year.

Output Format

Output a pinyin string representing the year name. Both the Heavenly Stem and the Earthly Branch should be in lowercase pinyin (without tones), and no extra characters should be added between them.

2020
gengzi

Hint

For all test cases, the input AD year is a positive integer not exceeding 99999999.

Lanqiao Cup 2020 National Contest, Group C, Problem F.

Translated by ChatGPT 5