ZOJ - 3594 Sexagenary Cycle(公元没有0年)
2015-04-17 02:34
351 查看
Sexagenary Cycle
Submit Status
Description
The Chinese sexagenary cycle, also known as the stems-and-branches, is a cycle of sixty terms used for recording days or years. Each term in the sexagenary cycle consists of two Chinese characters, the first representing a term from a cycle of ten known
as the heavenly stems and the second from a cycle of twelve known as the earthly branches. The first term (Jiazi) combines the first heavenly stem (Jia) with the first earthly branch (Zi). The second (Yichou) combines the second stem with the second branch.
This continues, generating a total of 60 different terms (the least common multiple of ten and twelve), after which the cycle repeats itself.
The ten heavenly stems are Jia, Yi, Bing, Ding, Wu, Ji, Geng, Xin, Ren and Gui. And the twelve earthly branches are Zi, Chou, Yin, Mao, Chen, Si, Wu, Wei, Shen, You, Xu and Hai. E.g. Xinhai Revolution occurred in 1911, the year of the Xinhai stem-branch
in the sexagenary cycle. And this year, namely 2012, is the year of Renchen. Given a year in western year, could you find out which year it is in cyclic year?
Actually, the cyclic year normally changes on the Chinese Lunar New Year, but you can ignore this in this problem.
Input
There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases.
Each test case contains a positive integer or a negative integer. A positive integer n indicates n AD (Anno Domini), while a negative integer nindicates -n BC
(Before Christ). The absolute values of all integers are strictly less than 10000.
Output
For each test case, output a string -- the corresponding cyclic year.
Sample Input
Sample Output
Time Limit: 2000MS | Memory Limit: 65536KB | 64bit IO Format: %lld & %llu |
Description
The Chinese sexagenary cycle, also known as the stems-and-branches, is a cycle of sixty terms used for recording days or years. Each term in the sexagenary cycle consists of two Chinese characters, the first representing a term from a cycle of ten known
as the heavenly stems and the second from a cycle of twelve known as the earthly branches. The first term (Jiazi) combines the first heavenly stem (Jia) with the first earthly branch (Zi). The second (Yichou) combines the second stem with the second branch.
This continues, generating a total of 60 different terms (the least common multiple of ten and twelve), after which the cycle repeats itself.
The ten heavenly stems are Jia, Yi, Bing, Ding, Wu, Ji, Geng, Xin, Ren and Gui. And the twelve earthly branches are Zi, Chou, Yin, Mao, Chen, Si, Wu, Wei, Shen, You, Xu and Hai. E.g. Xinhai Revolution occurred in 1911, the year of the Xinhai stem-branch
in the sexagenary cycle. And this year, namely 2012, is the year of Renchen. Given a year in western year, could you find out which year it is in cyclic year?
Actually, the cyclic year normally changes on the Chinese Lunar New Year, but you can ignore this in this problem.
Input
There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases.
Each test case contains a positive integer or a negative integer. A positive integer n indicates n AD (Anno Domini), while a negative integer nindicates -n BC
(Before Christ). The absolute values of all integers are strictly less than 10000.
Output
For each test case, output a string -- the corresponding cyclic year.
Sample Input
2 1911 2012
Sample Output
Xinhai Renchen
References
http://en.wikipedia.org/wiki/Sexagenary_cycle#include<iostream> #include<string> #include<cstring> using namespace std; const string firs[20] = { "Jia", "Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren", "Gui" }; const string seco[20] = { "zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen", "you", "xu", "hai" }; int main() { int year; int f, s; int casen; cin >> casen; while (casen--) { cin >> year; if (year < 0) year++; if (year < 0) year = year + 12000; cout << firs[(year+6) % 10] << seco[(year+8) % 12] << endl; } }
相关文章推荐
- ZOJ 3594 Sexagenary Cycle
- ZOJ-3594 Sexagenary Cycle【简单模拟】
- ZOJ 3594 Sexagenary Cycle
- zoj 3594 Sexagenary Cycle(模拟)
- ZOJ 3594 年份水题 【注意:没有0年】
- Sexagenary Cycle(干支纪年)
- Sexagenary Cycle(天干地支法表示农历年份)
- ZOJ3594 Sexagenary Cycle
- zoj3594 Sexagenary Cycle
- ZOJ 1005题解 这题数据有点问题没有按照题目要求也能被AC,我无语了。
- 发现一个Fragment没有走FragmentManager的registerFragmentLifecycleCallbacks的情况
- zoj 2760 How Many Shortest Path 求边不相交最短路的条数(没有重边)
- ZOJ 3591 & 3594
- ZOJ 2022题解,起初此题纠结了很久。方法没有用对,后经大牛指点恍然大悟,原来就是求1到N有多少是5的倍数,再求25的倍数,125的倍数如此循环。
- zoj 3130 最小费用最大流 (求 s到e 的两条总花费最少的 完全没有交点的 路径)
- F30A没有买到
- 《LoadRunner 没有告诉你的》之二——描述性统计与性能结果分析(续)
- zoj 1563
- 没有任何同步的Java多线程程序(高性能)
- ZOJ 2358 Sum of Factorials