Chinaunix首页 | 论坛 | 博客
  • 博客访问: 158538
  • 博文数量: 35
  • 博客积分: 2011
  • 博客等级: 大尉
  • 技术积分: 345
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-09 21:36
文章存档

2010年(10)

2009年(25)

我的朋友

分类:

2010-12-12 20:28:20

//POJ_1008

#include <stdio.h>
#include <string.h>
#define TZOLKIN_DAYS_PER_YEAR 260
#define TZOLKIN_NAME_CIRCLE 20
#define TZOLKIN_NUMBER_CIRCLE 13

int main(void)
{
    int n;//number of data

    int i;
    int all_days = 0;
    int days = 0;
    int haab_year, haab_month, haab_day;
    char str_haab_month[10];
    int tzolkin_year, tzolkin_name_index, tzolkin_number;
    char *str_tzolkin_name[20] = {"imix", "ik", "akbal", "kan", "chicchan",
                                "cimi", "manik", "lamat", "muluk", "ok",
                                "chuen", "eb", "ben", "ix", "mem", "cib",
                                "caban", "eznab", "canac", "ahau"};
    scanf("%d", &n);
    printf("%dn", n);

    for(i=0; i<n; i++)
    {
        scanf("%d. %s %d", &haab_day, str_haab_month, &haab_year);
        if(!strcmp(str_haab_month, "pop"))
            haab_month = 0;
        else if(!strcmp(str_haab_month, "no"))
            haab_month = 1;
        else if(!strcmp(str_haab_month, "zip"))
            haab_month = 2;
        else if(!strcmp(str_haab_month, "zotz"))
            haab_month = 3;
        else if(!strcmp(str_haab_month, "tzec"))
            haab_month = 4;
        else if(!strcmp(str_haab_month, "xul"))
            haab_month = 5;
        else if(!strcmp(str_haab_month, "yoxkin"))
            haab_month = 6;
        else if(!strcmp(str_haab_month, "mol"))
            haab_month = 7;
        else if(!strcmp(str_haab_month, "chen"))
            haab_month = 8;
        else if(!strcmp(str_haab_month, "yax"))
            haab_month = 9;
        else if(!strcmp(str_haab_month, "zac"))
            haab_month = 10;
        else if(!strcmp(str_haab_month, "ceh"))
            haab_month = 11;
        else if(!strcmp(str_haab_month, "mac"))
            haab_month = 12;
        else if(!strcmp(str_haab_month, "kankin"))
            haab_month = 13;
        else if(!strcmp(str_haab_month, "muan"))
            haab_month = 14;
        else if(!strcmp(str_haab_month, "pax"))
            haab_month = 15;
        else if(!strcmp(str_haab_month, "koyab"))
            haab_month = 16;
        else if(!strcmp(str_haab_month, "cumhu"))
            haab_month = 17;
        else if(!strcmp(str_haab_month, "uayet"))
            haab_month = 18;
        
        all_days = haab_year * 365 + haab_month * 20 + haab_day;
        tzolkin_year = all_days / TZOLKIN_DAYS_PER_YEAR;
        tzolkin_name_index = all_days % TZOLKIN_NAME_CIRCLE;
        tzolkin_number = all_days % TZOLKIN_NUMBER_CIRCLE + 1;

        printf("%d %s %dn", tzolkin_number, str_tzolkin_name[tzolkin_name_index], tzolkin_year);
    }

    return 0;
}

注:注意考虑一年中最后一天的情况,还有字符串一定不要拼错啊~!我就是因为有一个字符串拼错了结果白白的贡献了好几个WA。附上几组测试数据:

input

4. uayet 259

12. cumhu 1845

0. pop 260

1. pop 260

output

13 ahau 364

1 eznab 2591

1 imix 365

2 ik 365

 

Maya Calendar
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 42544 Accepted: 12964

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

Source


 

阅读(1618) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~