Maya Calendar - POJ 1008 时间转换
来源:互联网 发布:软件版本说明模板 编辑:程序博客网 时间:2024/06/13 19:07
Maya Calendar
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 64761 Accepted: 19965
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.
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.
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.
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
310. zac 00. pop 010. zac 1995
Sample Output
33 chuen 01 imix 09 cimi 2801
题意:让你由一种时间计量方式转换到另一种时间计量方式。
思路:没什么思路,就是注意一下 4. uayet 259,正解是 13 ahau 364而不是13 ahau 365(来自POJdiscuss)
AC代码如下:
#include<cstdio>#include<cstring>#include<string>#include<iostream>#include<map>using namespace std;map<string,int> match;int main(){ int t,i,j,k,day,day1,day2,year1,year2; char s1[100]; char c; string s2; string s3[]={"233","pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"}; string s4[]={"233","imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; for(i=1;i<=19;i++) match[s3[i]]=i; scanf("%d",&t); printf("%d\n",t); while(t--) { scanf("%d%c%s%d",&day1,&c,s1,&year1); k=match[s1]; day=year1*365+(match[s1]-1)*20+day1+1; //printf("day %d\n",day); year2=(day-1)/260; day-=year2*260; k=day%20; if(k==0) k=20; s2=s4[k]; day2=day%13; if(day2==0) day2=13; printf("%d ",day2); cout<<s2; printf(" %d\n",year2); }}
0 0
- Maya Calendar - POJ 1008 时间转换
- poj 1008 Maya Calendar(转换)
- POJ 1008 Maya Calendar
- poj 1008 Maya Calendar
- POJ 1008 Maya Calendar
- POJ 1008 Maya Calendar
- 【POJ】1008 Maya Calendar
- POJ-1008:Maya Calendar
- POJ 1008 Maya Calendar
- poj 1008 Maya Calendar
- POJ-1008-Maya Calendar
- POJ-1008-Maya Calendar
- POJ 1008/Maya Calendar
- poj 1008 Maya Calendar
- poj 1008 Maya Calendar
- [POJ][1008]Maya Calendar
- POJ 1008 Maya Calendar
- POJ - 1008 Maya Calendar
- Android命令行/c语言/java设置获取系统属性的方法
- error:MultiByteToWideChar cannot convert parameter 2 from 'char [10]' to 'unsigned short *'
- PL/SQL控制循环结构
- PLSQL程序控制结构
- 【Mac OS X开发】在NSAlert中添加NSTableView,双击NSTableView单元格用于确定选择的效果
- Maya Calendar - POJ 1008 时间转换
- 类簇的概念
- 《HTML 5网页开发实例详解》样章、内容简介、前言
- VxWorks Shell
- 中缀表达式转换成后缀表达式
- PLSQL更改数据及管理事务
- CAS 与 Spring Security 3.1整合配置详解
- Alpha测试与beta测试的区别
- WebRTC 学习笔记(1)--总述