字符串(KMP)
傻笨
这个作者很懒,什么都没留下…
展开
-
poj 2406
原来KMP中有好多知识点啊!这题就是求周期! 有一个公式: 如果 len%(len-next[len])==0的话,那么周期==len/(len-next[len]) 否则就是输出 1 代码如下: #include #include #include using namespace std; const int maxn=10000010;//这里注意不要开太大了,! int next1[原创 2013-09-04 19:50:30 · 470 阅读 · 0 评论 -
HDU 1711
这是一道KMP入门题目!直接套模板! #include #include #include using namespace std; const int maxn1=1000005; const int maxn2=10005; int next1[maxn2]; int s1[maxn1],s2[maxn2]; void getnext(int s2[],int lent) {原创 2013-09-04 15:27:40 · 493 阅读 · 0 评论 -
HDU 1686
这道题目和hdu2087差不多,都是求匹配数,但是又有点不同,不同点在于,当找到一个匹配后,HDU 2087是一定要从该主串匹配后一位开始进行匹配,而HDU 1686 则不同,是匹配后,然后可以从已经匹配好的字符串中开始进行匹配! HDU 1686代码如下: #include #include #include using namespace std; const int maxn1=10原创 2013-09-04 16:05:22 · 736 阅读 · 0 评论 -
HDU 3746
这道题目题目意思只要看懂这一句就知道了:Just like the pictrue below, this CharmBracelet's cycle is 9 and its cyclic count is 2 这道题目是KMP-----next数组的应用! 利用next来求循环周期!!! 代码如下: #include #include #include using name原创 2013-09-04 18:40:46 · 499 阅读 · 0 评论