#include<cstdio> #include<algorithm> #include<string> #include<cstring> #include<cmath> #include<iostream> using namespace std; int main() { int test,y=1; scanf("%d\n",&test); while(test--) { char s[100]; scanf("%s",&s); int i,j,k,l,m,n; string s1,s2,s3; s1=s; if(y>1)printf("\n"); y=2; char ch[100],dh[100]; for(i=1;i<strlen(s);i++) { if(strlen(s)%i==0) { for(j=0;j<i;j++)ch[j]=s[j]; ch[j]='\0'; strcpy(dh,ch); n=strlen(s)/i; for(j=0;j<n-1;j++)strcat(ch,dh); if(strcmp(s,ch)==0)break; } } printf("%d\n",i); } return 0; }
Sunday, August 17, 2014
uva : 455 - Periodic Strings
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment