zoj 3594 Sexagenary Cycle 农历 天干地支
来源:互联网 发布:服务器如何绑定域名 编辑:程序博客网 时间:2024/04/30 20:53
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
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3594
注意下公元没有0年,所以公元1年的前一年是公元前1年。
所以这题如果年份是公元前,那么要先+1 在加一个60的很大的倍数。
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <limits.h>#include <malloc.h>#include <ctype.h>#include <math.h>#include <string>#include <iostream>#include <algorithm>using namespace std;#include <stack>#include <queue>#include <vector>#include <deque>#include <set>#include <map> //Jia, Yi, Bing, Ding, Wu, Ji, Geng, Xin, Ren and Gui. //10 //Zi, Chou, Yin, Mao, Chen, Si, Wu, Wei, Shen, You, Xu and Hai//12string qian[10]={"Gui","Jia","Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren" };string hou[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) n++; n=n-1911+8; // n=// n-=2; int n2=n+4; n+=120000; n2+=120000; cout<<qian[n%10]<<hou[n2%12]<<endl;} return 0;}
- zoj 3594 Sexagenary Cycle 农历 天干地支
- ZOJ 3594 Sexagenary Cycle
- 农历天干地支算法
- ZOJ-3594 Sexagenary Cycle【简单模拟】
- zoj 3594 Sexagenary Cycle(模拟)
- android 获取农历日期和天干、地支
- ZOJ - 3594 Sexagenary Cycle(公元没有0年)
- 天干地支
- 天干地支
- 天干地支
- 天干、地支与五行
- 天干地支六十四卦
- 天干地支算法
- 天干地支六十四卦
- 天干地支的意义
- 天干地支读音
- 天干地支序号计算
- 农历天干地支算法源代码大全(javascript、vbscript、C#、flash、C++、C等等)
- File通过字符串创建对象的几种方式
- Java 习惯用法总结
- Struts中提示Invalid result location value/parameter
- JAVA 编译找不到符号
- 【leetcode】Binary Tree Postorder Traversal
- zoj 3594 Sexagenary Cycle 农历 天干地支
- HDU4720 Naive and Silly Muggles
- MATLAB文本文件操作总结
- 为什么业务层都要写一个接口
- web开发之在线人数统计
- 关于hashCode方法的作用
- Ant的安装和配置
- 蓝桥杯 取球游戏
- HDU 4725 The Shortest Path in Nya Graph