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 |
哪些大神们是怎么在0ms中完成的? 而且占用内存那么少? 有代码可看么?我的代码 #include <stdio.h> #include <string.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ char* hname[] = {"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"}; char* tname[] = {"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"}; int h_hash[]={7864320,6815744,204800,13107200,-1073741824,771751936,12582912,6291456,8192,768,800,1024,384,320,402653184,480,5242880,67108864,640}; unsigned int getHash(char* buf){ char* p = buf; unsigned int h= (*p-'a') << 5 + (*(p+1)-'a'); return h; } void pre(){ for(int i=0;i<19;i++){ printf("%d,",getHash(hname[i])); } } int getHM(char* buf){ int h = getHash(buf); for(int i=0;i<19;i++){ if(h == h_hash[i]) return i; } return -1; } int main(int argc,char** argv) { //pre(); int n ; int hy,hd,hm; char buf[4]; char* tp =NULL; scanf("%d",&n); printf("%d\n",n); int td,tm,ty; while(n -- >0){ scanf("%d. %s %d",&hd,&buf,&hy); hm = getHM(buf); long day = hy*365+ 20*hm + hd; //printf("hm = %d, day =%d",hm,day); td = day % 13 +1; tm = day % 20 ; tp = tname[tm]; ty = day / 260; printf("%d %s %d\r\n",td,tp,ty); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator