
kmp算法
文章平均质量分 75
刘da帅气
这个作者很懒,什么都没留下…
展开
-
POJ 1961 Period
求一个字符串在第几位上出现了循环节,输出位数 以及循环节的大小#include #include #include #include #include using namespace std;int main(){ char s[1000100]; int t; int Case = 1; while(~scanf("%d", &t)){原创 2017-04-08 20:12:12 · 269 阅读 · 0 评论 -
数据结构实验之串一:KMP简单应用
kmp算法的思想点击打开链接 当时学习思想的时候看的是这个地址,但是代码与他的思想略有不同,next数组第一个是-1 然后next[j]代表的是 前j-1 并不加上j数据结构实验之串一:KMP简单应用原创 2017-04-06 18:59:54 · 826 阅读 · 0 评论 -
数据结构实验之串三:KMP应用
数据结构实验之串三:KMP应用判断子串在主串中是否存在过一次,#include #include using namespace std;int text[11234567];int pattern[11234567];int n,m;void get(int pattern[], int next[]){ int i = 0,j = -1; next[原创 2017-04-06 20:24:04 · 1529 阅读 · 0 评论 -
poj 2406 Power Strings
题目链接求一个字符串的循环节为多大,直接用kmp的next的数组求法写#include #include using namespace std;char s[1123456];int next[1123456];int main(){ while(~scanf("%s", s)){ if(s[0] == '.'){ break;原创 2017-04-06 21:56:17 · 259 阅读 · 0 评论