Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<cstring>
- #include<cmath>
- #include<algorithm>
- #include<cstdlib>
- #include<sstream>
- #include<vector>
- #include<queue>
- #include<stack>
- //#include<bits/stdc++.h>
- #define pfl1(a) printf("%lld\n", a)
- #define sfl1(a) scanf("%lld", &a)
- #define sfl2(a,b) scanf("%lld %lld", &a, &b)
- #define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
- #define ll long long int
- #define MAX INT_MAX
- #define ffor(i,n) for(i=0;i<n;i++)
- #define mem(x,n) memset(x,n,sizeof(x))
- using namespace std;
- long long int x[999999];
- char s[999999],s2[999999];
- int main()
- {
- long long int a,b,c,d,e,v=0,w,y,i,j,k,l,m,n,p,q,r,t,z,sum;
- cin>>a;
- while(a--)
- {
- cin>>s;
- n=99;
- l=strlen(s);
- z=0;
- // if(v==1)cout<<endl;
- // v=1;
- for(i=1;i<l;i++)
- {
- if(s[0]!=s[i])z=1;
- }
- if(z==1&&l%2==1) {cout<<l<<endl;continue;}
- else if(z==0) {cout<<1<<endl;continue;}
- for(i=2;i<=l/2;i++)
- {
- k=l/i;
- z=0;
- // cout<<"\n\ni "<<i<<" k "<<k<<endl;
- for(p=0;p<i;p++)
- {
- j=k+p;
- for(;j<l;j+=k)
- {
- // cout<<"Start "<<p<<" Second "<<j<<endl;
- if(s[p]!=s[j])
- {
- z=1;
- break;
- }
- }
- }
- if(z==0&&k<n)n=k;
- }
- if(n==99)n=l;
- cout<<n<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement