| ||||||||||
| 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 | |||||||||
RTE...55555555555555555555#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int i,j;
long l,next[1000000];
char s[1000000];
scanf("%s",s);
while(s[0]!='.'||s[1])
{
l=strlen(s);
i=0;j=-1;next[0]=-1;
while(i<l)
{
if(j==-1||s[i]==s[j]){i++;j++;next[i]=j;}
else j=next[j];
}
if(s[l-1]!=s[next[l-1]]) cout<<1;
else cout<<l/(l-next[l-1]-1);
cout<<endl;
scanf("%s",s);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator