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> int main() { char s1[1000],s2[1000],s12[3000],s[3000]; int n,c,count,i,i1,i2,k; scanf("%d",&n); for(k=1;k<=n;k++) { scanf("%d",&c); scanf("%s",s1); scanf("%s",s2); scanf("%s",s12); count=0; while(1) { i1=0;i2=0; for(i=0;i<=2*c;i+=2) { s[i]=s2[i1++]; s[i+1]=s1[i2++]; } count++; if(strcmp(s,s12)==0)break; strncpy(s1,s,c); strcpy(s2,s+c); if(count==5000)break; } if(count==5000)printf("%d -1\n",k); else printf("%d %d\n",k,count); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator