Sexagenary Cycle


Time Limit: 2 Seconds      Memory Limit: 65536 KB

题目链接:zoj 4669

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

2
1911
2012

Sample Output

Xinhai
Renchen

References

  • http://en.wikipedia.org/wiki/Sexagenary_cycle
  • 题目大意:
  • 给出一个整数n,代表有n组数据,每组数据都有一个整数,代表年份,年份有负有正,负数代表的是公元前,正数代表的是公元后,求用天干地支法表示出每个年份。

与天干地支相关的资料链接:http://www.pep.com.cn/gzls/xs/lszs/201101/t20110110_1014103.htm

代码:

 #include<iostream>
#include<string.h>
using namespace std;
int main()
{
char f1[][]={"Xin","Geng","Ji","Wu","Ding","Bing","Yi","Jia","Gui","Ren"};
char g1[][]={"you","shen","wei","wu","si","chen","mao","yin","chou","zi","hai","xu"};
char f2[][]={"Geng","Xin","Ren","Gui","Jia","Yi","Bing","Ding","Wu","Ji","Geng"};
char g2[][]={"shen","you","xu","hai","zi","chou","yin","mao","chen","si","wu","wei","shen"};
int zong;
cin>>zong;
while(zong--)
{
int year;
cin>>year;
if(year>)
{
int yu=year%;
cout<<f2[yu];
yu=year%;
cout<<g2[yu];
cout<<endl;
}
else
{
int yu=(-*year)%;
cout<<f1[yu];
yu=(-*year)%;
cout<<g1[yu];
cout<<endl;
}
}
return ;
}

Sexagenary Cycle(天干地支法表示农历年份)的更多相关文章

  1. iOS 根据农历日期 获取当前的农历年份 即 干支纪年法算农历年

    前言:我国古代是用干支纪年的,近代史上提到的甲午战争.戊戌变法.辛亥革命等名词就是干支纪年.所谓干支就是十天干和十二地支的简称.天干.地支按照一定规则(单配单,双配双)可以搭配成60对,也就是一个甲子 ...

  2. C# 中国日历 农历 阳历 星座 二十四节气 二十八星宿 节日 天干地支

    using System; namespace DotNet.Utilities { /// <summary> /// 农历属性 /// </summary> public ...

  3. Java 实现输入公历日期输出农历日期、生肖、天干地支、节日、节气等信息

    最近的工作中客户要求前台页面展示日历,日历内容包括:农历年月日日.公历年月日.生肖.天干地支.农历节日.公历节日.24节气等信息,之前在网上查找资料关于Java实现方面的文章不少,但是大多数针对节气. ...

  4. [No0000156]天干地支-狗年我懂,戊戌二字怎么来的?

    话说,这几年的年份,总能让人联想到历史课本.比如,2014年是甲午马年,是中日甲午战争120周年.而2018年是戊戌狗年,嗯,戊戌变法也过去120年了…… 狗年相信大家都了解,小观前面两期关于反犬旁和 ...

  5. Java-获取年月日对应的天干地支

    一.概述 本次是以java语言开发为例,计算出年月日对应的天干地支. 二.代码 public class MyDate { /** * 对于年月日的天干地支 */ private int year_g ...

  6. 十二生肖&天干地支

    看相:http://baike.baidu.com/view/833122.htm?fr=aladdin 八字:http://baike.baidu.com/view/17127.htm?fr=ala ...

  7. jquery 带农历天干地支的日期选择控件

    效果图:

  8. 由.Net类库提供的农历计算

             由.Net类库提供的农历计算(C#农历)                 2007-11-21 12:47:00 标签:.Net 类库 农历计算 C#农历 休闲            ...

  9. c#实现万年历示例分享 万年历农历查询

    cs.cs(类页面) using System;using System.Collections.Generic;using System.Linq;using System.Web; namespa ...

随机推荐

  1. Mysql中索引的 创建,查看,删除,修改

    创建索引 MySQL创建索引的语法如下: ? 1 2 3 CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name [USING index_type] ON ...

  2. zabbix之Nginx安装

    转载自 http://www.ttlsa.com/nginx/nginx-install-on-linux/ Nginx下载 https://pan.baidu.com/s/1qXT54sO

  3. Http Request

    function getSend($url,$param) { $ch = curl_init($url."?".$param); curl_setopt($ch,CURLOPT_ ...

  4. backbone调试

    有一个谷歌的扩展程序:https://chrome.google.com/webstore/detail/backbone-debugger/bhljhndlimiafopmmhjlgfpnnchjj ...

  5. Service

      一.什么是Service Service在后台运行,不与用户进行交互.在默认情况下,Service运行在应用程序进程的主线程中,如果需要在Service中处理一些网络连接等耗时的操作,那么应该将这 ...

  6. pypi 国内镜像 及修改全局方法

    PyPi的官方网站为https://pypi.python.org,有时访问中会很慢,使用pip命令安装带其他依赖包的安装包,会经常失败.解决办法,使用国内PyPi镜像网站,修改pip的源. 网上搜索 ...

  7. C++ 中超类化和子类化常用API

    在windows平台上,使用C++实现子类化和超类化常用的API并不多,由于这些API函数的详解和使用方法,网上一大把.本文仅作为笔记,简单的记录一下. 子类化:SetWindowLong,GetWi ...

  8. NGUI Table页(UIToggle和UIToggledObjects)

    1.添加两个按钮Btn1和Btn2.添加2个Spr1和Spr2 2.给每个Btn添加两个脚本UIToggle和UIToggledObjects 3.将每个UIToggle的Group设置个非0的值 4 ...

  9. ACM/ICPC 之 DFS范例(ZOJ2412-ZOJ1008)

    通过几道例题简单阐述一下DFS的相关题型 ZOJ2412-Farm Irrigation 直观的DFS题型,稍加变化,记录好四个方向上的通路就能够做出来 题目和接水管类似,问最少要灌溉几次,即求解最少 ...

  10. ACM/ICPC 之 BFS(离线)+康拓展开 (HDU1430-魔板)

    魔板问题,一道经典的康拓展开+BFS问题,为了实现方便,我用string类来表示字符串,此前很少用string类(因为不够高效,而且相对来说我对char数组的相关函数比较熟),所以在这里也发现了很多容 ...