标签:des style blog http io ar color os sp
| Time Limit: 3000MS | Memory Limit: 65536K | |
| Total Submissions: 33623 | Accepted: 13966 |
Description
Input
Output
Sample Input
abcd aaaa ababab .
Sample Output
1 4 3
Hint
Source
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int next[1000002];
char s[1000002];
int len;
int get_next(char *s)
{
int i=0,j=-1;
next[0]=-1;
while(i<len)
{
if(j==-1||s[i]==s[j])
{
i++;
j++;
next[i]=j;
}
else
j=next[j];
}
if(len%(len-next[len])==0)
return len/(len-next[len]);
else
return 1;
}
int main()
{
while(gets(s)!=NULL)
{
if(s[0]=='.')
break;
len=strlen(s);
printf("%d\n",get_next(s));
}
return 0;
}标签:des style blog http io ar color os sp
原文地址:http://blog.csdn.net/hdd871532887/article/details/41710397