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:哪位大哥帮忙看看我的程序为什么会超时啊,help!!In Reply To:哪位大哥帮忙看看我的程序为什么会超时啊,help!! Posted by:project at 2004-11-09 21:02:38 定义那里len应为lens,哪位大哥帮帮忙! > 时间复杂度只有O(lenC×lenS)没什么可能超啊,请指教!thx! > > #include<stdio.h> > #include<string.h> > #include<math.h> > int main() > { > int x,i,j,n,d,lens,loop,k,m1,lenc,f1,f;char s[40],p[40],m[70],c[70]; > while(scanf("%d",&x)!=EOF){ > if(!x) break; > memset(s,'\0',40); > memset(p,'\0',40); > memset(m,'\0',70); > memset(c,'\0',70); > scanf("%s%s%s",s,p,c); > lenc=strlen(c); > d=((int)(sqrt(lenc*lenc*lenc)+x))%lenc; > lens=strlen(s); > for(i=0;i<lens;i++) > if(c[d]==s[i]) {n=i;break;} > m[d]=p[n]; > loop=0; > for(i=d;;i--){ > loop++;f=0;f1=0; > for(j=0;j<lens;j++){ > if(!f&&s[j]==m[(i+5*lenc)%lenc]){n=j;f=1;} > if(!f1&&s[j]==c[((i-1+5*lenc))%lenc]){m1=j;f1=1;} > if(f&&f1) break; > } > k=m1^n; > m[((i-1)+5*lenc)%lenc]=p[k]; > if(loop+1==lenc) break; > } > printf("%s\n",m); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator