Maya Calendar
Total Submission(s): 359 Accepted Submission(s): 158
For religious purposes, the Maya used another calendar in which the year was called Tzolkin (holly year). The year was divided into thirteen periods, each 20 days long. Each day was denoted by a pair consisting of a number and the name of the day. They used 20 names: imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau and 13 numbers; both in cycles.
Notice that each day has an unambiguous description. For example, at the beginning of the year the days were described as follows:
1 imix, 2 ik, 3 akbal, 4 kan, 5 chicchan, 6 cimi, 7 manik, 8 lamat, 9 muluk, 10 ok, 11 chuen, 12 eb, 13 ben, 1 ix, 2 mem, 3 cib, 4 caban, 5 eznab, 6 canac, 7 ahau, and again in the next period 8 imix, 9 ik, 10 akbal . . .
Years (both Haab and Tzolkin) were denoted by numbers 0, 1, : : : , where the number 0 was the beginning of the world. Thus, the first day was:
Haab: 0. pop 0
Tzolkin: 1 imix 0
Help professor M. A. Ya and write a program for him to convert the dates from the Haab calendar to the Tzolkin calendar.
NumberOfTheDay. Month Year
The first line of the input file contains the number of the input dates in the file. The next n lines contain n dates in the Haab calendar format, each in separate line. The year is smaller then 5000.
Number NameOfTheDay Year
The first line of the output file contains the number of the output dates. In the next n lines, there are dates in the Tzolkin calendar format, in the order corresponding to the input dates.
3 10. zac 0 0. pop 0 10. zac 1995
——————————————————————————————————————————————————————
先将时间转化为天数,然后再转化为对应格式的日期
/****************************
*Name:Maya Calendar.c
*Tags:ACM water
****************************/
#include <stdio.h>
#include <string.h>
int main()
{
char haab[19][10] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"};
char holly[20][10] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
int year, num, days, n, i;
char dayname[10];
scanf("%d", &n);
printf("%d\n", n);
while(n--) {
days = 0;
scanf("%d. %s %d", &num, dayname, &year);
/* printf("%d. %s %d\n", num, dayname, year); */
for(i = 0; i < 19; i++) {
if(strcmp(dayname, haab[i]) == 0) {
days = 20 * i + 365 * year + num;
break;
}
}
/* printf("days = %d\n", days); */
year = days / 260;
num = days % 13 + 1;
i = days % 20;
/* printf("i = %d\n", i); */
printf("%d %s %d\n", num, holly[i], year);
}
return 0;
}
3156



被折叠的 条评论
为什么被折叠?



