Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define mx 1000005
- 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 i;
- while(scanf("%s",text) && text[0]!='.')
- {
- len = strlen(text);
- for(i=1; i<=len; i++)
- {
- if(!(len%i))
- {
- if(compute_prefix(i))
- {
- break;
- }
- }
- }
- printf("%d\n",len/i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment