F - The Minimum Length HUST - 1010
题目链接:
题目:
There is a string A. The length of A is less than 1,000,000. I rewrite it again and again. Then I got a new string: AAAAAA...... Now I cut it from two different position and get a new string B. Then, give you the string B, can you tell me the length of the shortest possible string A. For example, A="abcdefg". I got abcd efgabcdefgabcdefgabcdefg.... Then I cut the red part: efgabcdefgabcde as string B. From B, you should find out the shortest A. InputMultiply Test Cases. For each line there is a string B which contains only lowercase and uppercase charactors. The length of B is no more than 1,000,000. OutputFor each line, output an integer, as described above.Sample Input
bcabcabefgabcdefgabcdeSample Output
37 题意:求最小循环节的长度 思路:kmp中n-next[n]就是最小循环节的长度,由于现在该题不支持提交,我就贴一下我写的
// // Created by HJYL on 2019/8/15.//#include#include #include