| ||||||||||
| 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 | |||||||||
超时,帮忙改进,付代码#include <iostream>
#include <stdlib.h>
#include <Cstring>
using namespace std;
int main ()
{
char s1[100000];
while (scanf("%s",&s1))
{
if(strcmp(s1,".")==0)
break;
int n=strlen(s1);
int i=0 , j=1,k=1;
while (j<n)
{
if(s1[j]!=s1[i])
{
j++;i=0;
k=j;
}
else if(s1[i]==s1[j])
{
i++;j++;
}
}
if(n%k == 0)
cout << n/k << endl;
else cout << "1" <<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator