![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
KMP
萧瑟1
这个作者很懒,什么都没留下…
展开
-
HDU 1711 Number Sequence KMP模板题
题目:传送门思路:KMP模板题目代码如下:#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>using namespace std;const int maxn=1e6+5;const int maxm=1e4+5;i...原创 2019-01-19 16:05:35 · 172 阅读 · 0 评论 -
HDU 2203 亲和串 KMP变式
题目:传送门思路:因为此题后面的字符与前缀字符串组成的字符串也可以进行判断,所以首先想到的最简单的方法是将要判断的字符串*2,这样就可以套用KMP算法了。代码如下:#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>using...原创 2019-01-19 16:57:47 · 162 阅读 · 0 评论 -
HDU 1358 Period
题目:传送门题意:给出一个字符串,求出前缀字符串中是周期串的长度和周期数(周期数大于1)。思路:利用KMP求出前缀表p[],看看每个前缀串的长度减去前缀表是否可以被前缀串的长度整除,即len%(len-p[len])==0?,即len-p[len]就为周期串的周期长度,len/(len-p[len])即为周期数。代码如下:#include <cstdio>...原创 2019-01-20 14:15:52 · 129 阅读 · 0 评论 -
HDU 3746 Cyclic Nacklace KMP应用
题目:CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinking about h...原创 2019-01-21 12:21:52 · 123 阅读 · 0 评论 -
HDU 2594 Simpsons’ Hidden Talents KMP
题目:Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in polit...原创 2019-01-21 16:30:30 · 151 阅读 · 0 评论