标签:nbsp contain integer ble ges concat i++ 16px 循环
Time Limit: 3000MS | Memory Limit: 65536K | |
Description
Input
Output
Sample Input
abcd aaaa ababab .
Sample Output
1 4 3
Hint
#include<cstdio> #include<cstring> #include<iostream> using namespace std; int n; char s[1000001]; int f[1000010]; void getnext() { for(int i=1;i<n;i++) { int j=f[i]; while(j&&s[i]!=s[j]) j=f[j]; f[i+1]= s[i]==s[j] ? j+1:0; } } int main() { while(cin>>s) { if(s[0]==‘.‘) break; n=strlen(s); getnext(); int ans=n-f[n]; if(n%ans) printf("1\n"); else printf("%d\n",n/ans); } }
标签:nbsp contain integer ble ges concat i++ 16px 循环
原文地址:http://www.cnblogs.com/TheRoadToTheGold/p/6484712.html