标签:time put pac void least get std str follow
Time Limit: 3000MS | Memory Limit: 65536KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
abcd aaaa ababab .
Sample Output
1 4 3
Hint
#include<iostream> #include<cstring> #include<cstdio> using namespace std; #define N 1000009 char s[N]; int next[N]; int l; void getnext() { l=strlen(s); next[0]=-1; for(int i=1,j;i<l;i++) { j=next[i-1]; while(s[i]!=s[j+1]&&j>=0) j=next[j]; next[i]=s[i]==s[j+1]?j+1:-1; } if(l%(l-next[l-1]-1)==0) printf("%d\n",l/(l-next[l-1]-1)); else printf("%d\n",-1); } int main() { while(scanf("%s",s)) { getnext(); } return 0; }
标签:time put pac void least get std str follow
原文地址:https://www.cnblogs.com/zzyh/p/6853602.html