KMP
oopslb
这个作者很懒,什么都没留下…
展开
-
最小循环子串
定理:假设S的长度为len,则S存在最小循环节,循环节的长度L为len-next[len],子串为S[0…len-next[len]-1]。 (1)如果len可以被len - next[len]整除,则表明字符串S可以完全由循环节循环组成,循环周期T=len/L。 (2)如果不能,说明还需要再添加几个字母才能补全。需要补的个数是循环个数L-len%L=L-(len-L)%L=L-next[le...原创 2018-07-27 10:47:25 · 6504 阅读 · 0 评论 -
2018牛客多校第三场 E Sort String (最小循环节)
题目思路:模拟几个字符串就会发现规律,跟最小循环节有关。只要用Next数组找到最小循环节就可以了。代码:#include<stdio.h>#include<string.h>using namespace std;const int N=1e6+10;char c[N];int Next[N];void init(int n){ int i...原创 2018-07-27 11:05:54 · 168 阅读 · 0 评论