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 |
你整个环求的当然会tle,我单个求得都tle了。。。In Reply To:Re:大牛门来帮小弟看看呀,怎么就TLE了啊//我都求了模了 Posted by:526496390 at 2008-03-20 15:01:52 > #include<stdio.h> > #include<stdlib.h> > #include<string.h> > void trans(char a[210],int b[210],int n); > > int main(void) > { > int n; > scanf("%d",&n); > while(n!=0) > { > int huan=0; > int times; > int i; > int change[210]; > char test[210]; > char mirror[210]; > for(i=0;i<n;i++) > scanf("%d",&change[i]); > scanf("%d",×); > while(times!=0) > { > getchar(); > gets(test); > > trans(test,change,n); > strcpy(mirror,test); > times--; > while(times>0) > { > trans(test,change,n); > times--; > if(strcmp(test,mirror)!=0) > { > > huan++; > } > else > { > times%=huan; > times--; > } > } > while(test[n-1]==' ') > { > n--; > } > test[n]='\0'; > printf("%s\n",test); > scanf("%d",×); > } > scanf("%d",&n); > } > return 0; > } > void trans(char a[210],int b[210],int n) > { > char temp[210]; > int i=(int)strlen(a); > for(;i<=n;i++) > { > a[i]=' '; > } > for(i=0;i<n;i++) > temp[b[i]-1]=a[i]; > for(i=0;i<n;i++) > a[i]=temp[i]; > a[i]='\0'; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator