Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define mx 90
- using namespace std;
- char text[mx];
- int len;
- bool compute_prefix(int i)
- {
- for(int j=i;j<len;j++)
- {
- if(text[j]!=text[j%i])
- {
- return false;
- }
- }
- return true;
- }
- int main()
- {
- int test,tc,i;
- scanf("%d",&test);
- for(tc=1; tc<=test; tc++)
- {
- scanf("%s",text);
- len = strlen(text);
- for(i=1;i<=len;i++)
- {
- if(!(len%i))
- {
- if(compute_prefix(i))
- {
- break;
- }
- }
- }
- printf("%d\n",i);
- if(tc<test)
- {
- puts("");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment