| ||||||||||
| 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 | |||||||||
错误的童鞋可以看一下注意一下aaac和aabaabaa这两种情况
#include<cstdio>
#include<cstring>
using namespace std;
int i,j,len;
char s[1000010];
void getnext(){
i=1,j=0;
while(i<len){
if(s[i]==s[j]){
i=i+1;
j=j+1;
}
else{
j=0;
i++;
}
}
}
int main(){
while(scanf("%s",&s)!=EOF){
if(s[0]=='.'){
return 0;
}
else{
len=strlen(s);
}
getnext();
if(len%(i-j)!=0){
printf("1\n");
}
else
printf("%d\n",len/(i-j));
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator