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. zabbix之MySQL数据库的安装

    转载自:http://www.ttlsa.com/mysql/install-mysql5_6/ 启动MySQL并制定套接字 mysql -u user -ppassword -S 指定socket路 ...

  2. 使用uwsgi 部署python web服务

    uwsgi, wsgi协议的一个很好的实现,源码在这里:https://github.com/unbit/uwsgi c语言编写,有兴趣可以研究下. 上DEMO: wsgi_server.py def ...

  3. Linux查看文件编码格式及文件编码转换

    Linux查看文件编码格式及文件编码转换   如果你需要在Linux 中操作windows下的文件,那么你可能会经常遇到文件编码转换的问题.Windows中默认的文件格式是GBK(gb2312),而L ...

  4. Adapter

    11-25 16:09:10.965 22791-22823/myapplication.com.myblue E/HAL: hw_get_module_by_class: lib loaded: / ...

  5. 【GoLang】golang 微服务框架 介绍

    原文如下: rpcx是一个类似阿里巴巴 Dubbo 和微博 Motan 的分布式的RPC服务框架,基于Golang net/rpc实现. 谈起分布式的RPC框架,比较出名的是阿里巴巴的dubbo,包括 ...

  6. 【GoLang】GoLang map 非线程安全 & 并发度写优化

    Catena (时序存储引擎)中有一个函数的实现备受争议,它从 map 中根据指定的 name 获取一个 metricSource.每一次插入操作都会至少调用一次这个函数,现实场景中该函数调用更是频繁 ...

  7. PageImpl是不是有问题?

    pageable.getOffset() + content.size() : total这个API 感觉没有实现该有的功能!!!

  8. C# 毕业证书打印《二》

    当证书的打印功能得以实现,最关键的功能便是数据. 通过对打印的了解,打印中最关键的功能便是打印事件中的方法. private void pd_PrintPage(object sender, Prin ...

  9. 如何让您的php也支持pthreads多线程

    我们常常会碰到这样一种情况,开发环境在windows下开发,而生产环境确是linux.windows下能正常运行,上传到linux后却无法好好地玩耍了.然后开始了一轮尼玛式的疯狂的查找原因,最后发现是 ...

  10. 数据结构——B树、B+树

    B树和B+树主要应用于外排序,对于外排序,从硬盘读取的时间要远远大于遍历树的时间,因此要想办法减少从硬盘读取的时间. B树(有时也叫B-树) M阶B树定义如下: 是一种多路搜索树(并不是二叉的):1. ...