随笔分类 - 字符串-KMP
摘要:题面:https://www.luogu.org/problemnew/show/P4391 cpp 本题中n next[n]即为字符串最小长度的循环节。 Code: include include include include include include using namespace st
阅读全文
摘要:题面:http://poj.org/problem?id=1961 cpp 本题的重点在于如果一个串是周期串的话,那么每次错位的位置应该是一个循环节。所以当i next[i]=x i时,此时next[i]就是一个循环节。 Code: include include include include i
阅读全文
摘要:题面:http://poj.org/problem?id=2406 cpp 本题中的可能的最短循环节即为KMP中的next[len 1],若len next[len 1]能被len整除,则有最短循环节,否则输出1。 Code: include include include using namesp
阅读全文
摘要:```cpp int[] getNext(String ps){ next[0]= 1; int j=0; int k= 1; while(j
阅读全文

浙公网安备 33010602011771号