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. windows 下安装 mysql

    1.根据系统,选择下载mysql community server(32/64) 版本 2.解压下载的文件 3.配置环境变量 将mysql目录下的bin目录路径配置到环境变量Path中,如下图所示 4 ...

  2. 30 GroupSock(Port)——live555源码阅读(四)网络

    30 GroupSock(Port)——live555源码阅读(四)网络 30 GroupSock(Port)——live555源码阅读(四)网络 简介 Port类的定义 Port的构造与全局的 &l ...

  3. yuv转bmp

    #ifdef _INTERFACE_H #error _INTERFACE_H has be exsisted #else #define _INTERFACE_H #include "st ...

  4. 【GoLang】GoLang 错误处理 -- 使用异常的思路进行处理

    go处理错误的另一种方式 go处理错误常见的方式是 err := funcReturningError() if err != nil { // 处理错误 } 然而因为过于繁琐而饱受诟病.下文简述另一 ...

  5. poj 2153

    题意:题目还是很简单的,就是求Li Ming 在班上的排名,而且成绩是相加的. 思路:用map就行.不然好像用qsort+二分也可以,不过我在那里碰到了一些状况,然后就没用这种方法了,简单的map就可 ...

  6. C++实现VPN工具之VPN错误代码大全

    该篇文章转自:<VPN问题全攻略>http://home.51.com/h012359/diary/item/10008457.html 以下是使用VPN版软件中常见的一些错误代码: 1. ...

  7. Java中时间日期格式化

    1.与日期时间相关的类:      第一:java.util.Date;                           将时间作为一个整体使用.处理时,使用Date类较为简便      第二:j ...

  8. Java for LeetCode 215 Kth Largest Element in an Array

    Find the kth largest element in an unsorted array. Note that it is the kth largest element in the so ...

  9. Python缩小图像

    LyncLynn用途: 缩小图像 # -*- coding: UTF-8 -*- #Version: V1.0 #Author:lynclynn #CreateDate:20151201 #Updat ...

  10. Divide and conquer:Dropping tests(POJ 2976)

    最大化平均值 题目大意:给定你n个分数,从中找出k个数,使∑a/∑b的最大值 这一题同样的也可以用二分法来做(用DP会超时,可见二分法是多么的实用呵!),大体上是这样子:假设最大的平均值是w,那么题目 ...