题目大意:两种历法的转换,注意转换后的历法类似于干支纪年法,月和日单独循环。
题目链接:http://poj.org/problem?id=1008
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define MAXN 10
char Haab[19][MAXN]={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin",
"mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"};
char Tzolkin[20][MAXN]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat",
"muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
int getday(int d,char m[],int y)
{
int day=0;
day+=y*365;
int mm;
for(mm=0;mm<19;mm++)
{
if(strcmp(m,Haab[mm])==0)
break;
}
day+=mm*20;
day+=d;
return day;
}
int main()
{
int n;
scanf("%d",&n);
printf("%d\n",n);
while(n--)
{
int day;
char month[MAXN];
int year;
scanf("%d. %s %d",&day,month,&year);
int num=getday(day,month,year);
int y=num/260;
int m=num%13+1;
int d=num%20;
printf("%d %s %d\n",m,Tzolkin[d],y);
}
return 0;
}