标签:
#include<stdio.h> #include<string.h> const int MAXN = 1e6+7; const int oo = 1e9+7; char s[MAXN]; int next[MAXN]; void GetNext(int N) { int i=0, j=-1; next[0] = -1; while(i < N) { if(j==-1 || s[i]==s[j]) next[++i] = ++j; else j = next[j]; } } int main() { while(scanf("%s", s) != EOF) { int N = strlen(s); GetNext(N); printf("%d\n", N-next[N]); } return 0; }
The Minimum Length - HUST 1010(求最小循环节)
标签:
原文地址:http://www.cnblogs.com/liuxin13/p/4730929.html