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:ustcxiaofeng at 2009-03-12 10:43:49 #include "stdio.h" #include "string.h" #define MAXN 300 char s[MAXN]; int a,b,len; void init() { int i; len=256; for (i=0;i<len;i++) if (s[i]<65) s[i]=s[i]-48; else s[i]=s[i]-55; } void work() { int i,add,t; i=a=b=0; do { switch(s[i]) { case 0: add=s[i+1]*16+s[i+2]; a=s[add]; i+=3; break; case 1: add=s[i+1]*16+s[i+2]; s[add]=a; i+=3; break; case 2: t=a; a=b; b=t; i++; break; case 3: t=a+b; a=t%16; b=t/16; i++; break; case 4: a=(a+1)%16; i++; break; case 5: a--; if (a<0) a=15; i++; break; case 6: if (a==0) i=s[i+1]*16+s[i+2]; else i+=3; break; case 7: i=s[i+1]*16+s[i+2]; i++; break; case 8: return; } } while (1); } void output() { int i; for (i=0;i<len;i++) if (s[i]>10) s[i]=s[i]+55; else s[i]=s[i]+48; puts(s); } int main() { int f=1,i; gets(s); while (s[0]!='8') { init(); work(); output(); gets(s); } return 0; } 我的和上面的程序基本一样,怎么会TLE? Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator