zoj 3594 Sexagenary Cycle(模拟)
来源:互联网 发布:中序线索树的递归算法 编辑:程序博客网 时间:2024/04/30 11:47
转载请注明出处:http://blog.csdn.net/u012860063
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4678
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 n indicates -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
219112012
Sample Output
XinhaiRenchen
References
- http://en.wikipedia.org/wiki/Sexagenary_cycle
Author: WU, Zejun
Contest: The 12th Zhejiang University Programming Contest
题意:
就是告诉你1911年为辛亥年 要你求其他年;
注意:60一个轮回,且题目会有负的年份输入;那么就要分开考虑正负年份;为负的时候还要考虑0什么也不是的情况,分别考虑天干和地支!
题目中地支是大写 但是案例中地支由于在天干后面 首字母就是小写了,就因为这白白WA了一次 ,
代码如下:
#include <stdio.h>#include <string>#include <iostream>using namespace std;string a[10]={"Gui","Jia","Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren"};string b[12]={"hai","zi","chou", "yin", "mao", "chen", "si", "wu", "wei", "shen", "you", "xu"};//注意数组顺序,把最后一个放到最前面int main(){int t;cin>>t;int n;while(t--){ cin >> n; if(n < 0)//0 什么年也不是,没有公元元年 { n++; } n = n-1911+8; //xin为a[8] int n2 = n-8; //hai为b[0] n+=120000; n2+=120000; int t1 = n%10; int t2 = n2%12; cout<<a[t1]<<b[t2]<<endl;}return 0;}
- zoj 3594 Sexagenary Cycle(模拟)
- ZOJ-3594 Sexagenary Cycle【简单模拟】
- ZOJ 3594 Sexagenary Cycle
- ZOJ - 3594 Sexagenary Cycle(公元没有0年)
- zoj 3594 Sexagenary Cycle 农历 天干地支
- Sexagenary Cycle(干支纪年)
- ZOJ3594 Sexagenary Cycle
- ZOJ 1138(模拟)
- ZOJ 2686 Cycle Game(博弈 找规律)
- ZOJ Fiddlesticks (简单模拟)
- ZOJ 3897(模拟题)
- ZOJ 3705Applications (模拟)
- ZOJ 3323(B)模拟
- ZOJ 3326(E)模拟
- ZOJ 3333(L)模拟
- ZOJ 3705 Applications (模拟)
- ZOJ——2971(模拟)
- POJ 1575/ZOJ 1698(模拟)
- hrbust2090背包(经典。。,想不到就有点难)
- structs与ajax结合的问题
- jQuery.validator.addMethod实例
- ActivityGroup window bad token问题深入分析
- 设计模式研究之——单例模式
- zoj 3594 Sexagenary Cycle(模拟)
- HDU 斜率优化dp 3507 Print Article
- 黑马程序员_IO流(二)
- ABAP 学习之旅(索引篇)
- Hadoop在MapReduce中使用压缩详解
- IT项目(公司)管理小技巧
- Struts2 工作原理
- 数据结构树之二叉树
- 输出素数(输入N之间)