ZOJ-3594 Sexagenary Cycle【简单模拟】

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4678

题目大意:

给你天干地支,60一个轮回,1911年为辛亥年。

以此为基础,计算给定一个数用这种方式怎么表达。


解题思路:

当时别人说的题,可惜没说有负的(公元前Orz),然后一直越界,我还纳闷了。

之后突然看见可以有负的。。。。郁闷啊。改了一下就过了。


代码如下:

#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;

char a[10][5] = {"Jia", "Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren", "Gui"};
char b[12][5] = {"zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen", "you", "xu", "hai"};
string c[65];

void fun() //0-59打表~
{
	for(int i = 0, j = 0, num = 0; (i < 10 || j < 12) && num < 60; i = (i + 1) % 10, j = (j + 1) % 12, num++)
	{
		c[num] += a[i]; 
		c[num] += b[j];
	}
}

int main()
{
	int ncase;
	fun();
	scanf("%d", &ncase);
	while(ncase--)
	{
		int n;
		scanf("%d", &n);
		if(n > 0)
		{
			int temp = n % 60;
			cout<<c[(temp + 56) % 60]<<endl;
		}
		else
		{
			int temp = n % 60;
			temp = (57 - abs(temp) + 60) % 60;
			cout<<c[temp]<<endl;
		}
	}
	return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值