Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:数据都没问题!!为什么还是没法让我睡呢??各位,救救我吧In Reply To:Re:数据都没问题!!为什么还是没法让我睡呢??各位,救救我吧 Posted by:sehdan at 2009-01-02 12:48:33 我蛮干的代码,题目数据量不大,所以没去做哈希以及查找的优化。 更好的方法是对月份做哈希,或者至少对月份的关键字排序以后索引的时候用二分查找。 (但本题数据量很小,这样做貌似有点小题大做了。。。) 在大牛们面前献丑了。。。。 #include <iostream> #include <cstdio> #include <cstring> using namespace std; char haab_m[][10]={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin","mol", "chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet" }; char Tzolkin[][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat", "muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau" }; int find_haab(char src[]) { for(int i = 0; i < 19; i++) { if(!strcmp(src,haab_m[i])) return i; } return -1; } int main() { int ncase; scanf("%d", &ncase); printf("%d\n", ncase); int haab_day,haab_years; int Tzolkin_year,Tzolkin_num; char tmp,haab_month[10]; int total_days; while(ncase--) { scanf("%d%c%s%d",&haab_day,&tmp,haab_month,&haab_years); total_days = haab_years * 365 + find_haab(haab_month)*20 + haab_day; Tzolkin_year = total_days / 260; int temp_days(total_days % 260); Tzolkin_num = temp_days % 13; printf("%d %s %d\n",Tzolkin_num + 1,Tzolkin[(temp_days) % 20], Tzolkin_year); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator