/*
* 最小循环节
* abcabc : 3;
* abcd : 4;
* abca : 3;
*/
#include "bits/stdc++.h"
using namespace std;
const int N = 100005;
char s[N];
int ne[N];
int main(){
while(cin>>s+1) {
int len = strlen(s + 1);
for (int i = 2, j = 0; i <= len; i++) {
while (j && s[i] != s[j + 1]) j = ne[j];
if (s[i] == s[j + 1]) j++;
ne[i] = j;
}
cout << len - ne[len] << endl;
}
return 0;
}
04-20
1333
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交