首页 文章详情

poj 1008 Maya Calendar

C语言题库 | 225 2021-10-12 13:20 0 0 0
UniSMS (合一短信)

Maya Calendar


Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 92229
Accepted: 28221

Description

During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, professor discovered that the Maya civilization used a 365 day long year, called Haab, which had 19 months. Each of the first 18 months was 20 days long, and the names of the months were pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu. Instead of having names, the days of the months were denoted by numbers starting from 0 to 19. The last month of Haab was called uayet and had 5 days denoted by numbers 0, 1, 2, 3, 4. The Maya believed that this month was unlucky, the court of justice was not in session, the trade stopped, people did not even sweep the floor.

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.

Input

The date in Haab is given in the following format:
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.

Output

The date in Tzolkin should be in the following format:
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.

Sample Input

3
10. zac 0
0. pop 0
10. zac 1995

Sample Output

3
3 chuen 0
1 imix 0
9 cimi 2801



玛雅历法


描述

在他最后的休假期间,m.a. Ya教授对古玛雅历法有了惊人的发现。从一条古老的信息中,教授发现玛雅文明一年365天,叫做哈伯,有19个月。前18个月的每个月都有20天,月名是pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu。没有名称,月份的天数用从0到19的数字表示。哈伯的最后一个月叫做uayet,有5天,用数字0、1、2、3、4表示。玛雅人认为这个月不吉利,法院不开庭,贸易停止,人们甚至不扫地。

出于宗教目的,玛雅人使用了另一种历法,在这种历法中,这一年被称为“卓尔金年”(holy year)。一年分为13个时期,每个时期有20天。每一天都用一个数字和日期组成的一对来表示。他们用了20个名字:imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau和13个数字;在周期。

请注意,每一天都有明确的描述。例如,在一年开始时,对日子的描述如下:

本土知识1 imix, 2、3 akbal 4菅直人5 chicchan 6 cimi 7马尼克,8 lamat 9 muluk 10好了,11个村,12 eb, 13本,1第九,2 mem 3 cib 4 caban 5 eznab 6 canac 7 ahau,又在下一期8 imix 9本土知识,10 akbal。。。

年份(Haab和zolkin)用数字0,1,:::表示,其中数字0是世界的开始。因此,第一天是:

Haab: 0。流行0

1混和0

帮助m.a. Ya教授,为他写一个程序,把哈伯日历的日期转换成卓尔金日历。


输入

Haab内的日期格式如下:

NumberOfTheDay。月年

输入文件的第一行包含文件中输入日期的编号。接下来的n行包含n个Haab日历格式的日期,每个日期在单独的行中。这一年比5000年还小。


输出

zolkin版本的日期格式如下:

NameOfTheDay数年

输出文件的第一行包含输出日期的编号。在接下来的n行中,有zolkin日历格式的日期,顺序与输入日期相对应。


Sample Input

3
10. zac 0
0. pop 0
10. zac 1995

Sample Output

3
3 chuen 0
1 imix 0
9 cimi 2801




题意:

  (有中文版题目。。)

   就是两种历法的转换

 

思路:

  把两种历法的细节了解了就很简单了

  Haab历法一年365,Tzolkin一年260天

  先求出总天数sumDay,然后sumDay/260就是Tzolkin历的年份

  T历的天名称20一循环,我们只需建立名称与1-20的关系就行,对20取模即可

  T历的天数字同理可得到

  (注意输入输出格式!)


代码:

#include <stdio.h>

int getHmonth(char *Hmonth){
int i,asciiSum=0;
for(i=0;Hmonth[i];i++){
asciiSum+=Hmonth[i];
}
//将H历每个月份所含字母的ascii码求和,利用swich语句得到对应第几个月(注意从0开始的)
switch(asciiSum)
{
case 335:
return 0;
case 221:
return 1;
case 339:
return 2;
case 471:
return 3;
case 438:
return 4;
case 345:
return 5;
case 674:
return 6;
case 328:
return 7;
case 414:
return 8;
case 338:
return 9;
case 318:
return 10;
case 304:
return 11;
case 305:
return 12;
case 636:
return 13;
case 433:
return 14;
case 329:
return 15;
case 534:
return 16;
case 546:
return 17;
case 552:
return 18;
}
}
int main()
{
char Tday[21][10]={"ahau","imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int i,n;
scanf("%d",&n);
printf("%d\n",n);
int sumDay,Hyear,Hday,hMonthNum;
char Hmonth[10];
for(i=0;i<n;i++)
{
scanf("%d. %s %d",&Hday,Hmonth,&Hyear);
hMonthNum=getHmonth(Hmonth);
sumDay=365*Hyear+Hday+hMonthNum*20;
printf("%d %s %d\n",sumDay%13+1,Tday[sumDay%20+1],sumDay/260);
}
return 0;
}


good-icon 0
favorite-icon 0
收藏
回复数量: 0
    暂无评论~~
    Ctrl+Enter