Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 59578 | Accepted: 18352 |
Description
Input
Output
Sample Input
3 10. zac 0 0. pop 0 10. zac 1995
Sample Output
3 3 chuen 0 1 imix 0 9 cimi 2801
#include <iostream> #include <string> using namespace std; int main() { int lines=0; int i=0, j=0; char ret[5000][20]; cin>>lines; string Haab[19] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"}; string Tzol[20] = {"ahau", "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac"}; for(i=0; i<lines; i++) { int idays=0, imonth=0; string s1,s2,s3; cin>>s1>>s2>>s3; for(j=0; j<19; j++) { if(s2 == Haab[j]) { imonth = j; break; } } idays = 1+atoi(s1.c_str())+20*imonth+365*atoi(s3.c_str()); int newday = idays%13; if(newday==0) newday = 13; int newmon = idays%20; int newyea = (idays-1)/260; sprintf(ret[i], "%d %s %d\0", newday, Tzol[newmon].c_str(), newyea); } printf("%d\n", lines); for(i=0; i<lines; i++) printf("%s\n", ret[i]); return 0; }
成绩对比:
1 1572183 trymuchmore 4K 0MS Pascal 852B 2006-09-09 17:48:39
10 2389903 xxsp 8K 0MS C++ 659B 2007-07-25 22:20:42
7552 11836232(2) dragoo1 344K 0MS C++ 1040B 2013-07-22 21:58:59
其他代码:
//http://blog.csdn.net/lyy289065406/article/details/6645413 //Memory Time //264K 0MS #include<iostream> using namespace std; /*得到Haab历月份对应的数字*/ int GetMonth(char* month) { int ASCII=0; for(int i=0;month[i];i++) ASCII+=month[i]; switch(ASCII) { case 335:return 1; //pop case 221:return 2; //no case 339:return 3; //zip case 471:return 4; //zotz case 438:return 5; //tzec case 345:return 6; //xul case 674:return 7; //yoxkin case 328:return 8; //mol case 414:return 9; //chen case 338:return 10; //yax case 318:return 11; //zac case 304:return 12; //ceh case 305:return 13; //mac case 636:return 14; //kankin case 433:return 15; //muan case 329:return 16; //pax case 534:return 17; //koyab case 546:return 18; //cumhu case 552:return 19; //uayet } } /*计算Haab历从第0天到现在的天数*/ int HaabDay(int day,int month,int year) { int sumday=0; for(int i=0;i<year;i++) //Haab历法一年有365天 sumday+=365; for(int j=1;j<month;j++) sumday+=20; return sumday+day; } int main(void) { char TzolkinDayName_Str[21][10]={"0","imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"}; int day; char doc; //注意输入格式有 "." char month[10]; int year; int test; cin>>test; cout<<test<<endl; while(test-- && (cin>>day>>doc>>month>>year)) //日期. 月份 年数 { int sumday=HaabDay(day,GetMonth(month),year); int TzolkinYear=sumday/260; //Tzolkin历法一年有260天 int TzolkinDayName=sumday%20+1; int TzolkinDayId=sumday%13+1; cout<<TzolkinDayId<<' '<<TzolkinDayName_Str[TzolkinDayName]<<' '<<TzolkinYear<<endl; } return 0; }