kmp练习poj1961
来源:互联网 发布:淘宝专柜价是正品吗 编辑:程序博客网 时间:2024/06/10 21:22
题意
求出所有前缀串的最小循环节长度
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int maxn = 1000005;char p[maxn];int f[maxn];int main(){ int n,cas = 1; while(scanf("%d",&n) && n) { scanf("%s",p); f[0] = f[1] = 0; int len = strlen(p); for(int i=1; i<len; i++) { int j = f[i]; while(j && p[i] != p[j]) j = f[j]; if(p[i] == p[j]) f[i+1] = j + 1; else f[i+1] = 0; } printf("Test case #%d\n",cas++); for(int i = 2; i<=len; i++) { int x = i - f[i]; if(f[i] && i%x == 0) printf("%d %d\n",i,i/x); } printf("\n"); } return 0;}
0 0
- kmp练习poj1961
- poj1961---KMP
- POJ1961->KMP
- 【KMP】 poj1961 Period
- poj1961 Period----KMP
- poj1961 kmp 重复串
- LA3026||poj1961(KMP)
- poj1961之KMP应用
- poj1961 Period (KMP)
- poj1961 KMP
- KMP POJ1961 Period
- [POJ1961]Period(KMP)
- poj1961 Period(KMP)
- POJ1961 Period(KMP)
- kmp算法 和例题 poj1961
- poj1961 KMP求循环节
- POJ1961(KMP-Next数组)
- poj1961 KMP(循环节)
- 施一公:如何做一名优秀的博士生
- IOS OpenGLES2.0 入门02 绘制三角形
- 瀑布流布局神器——JQuery Masonry
- 算法
- 有了malloc/free为什么还要new/delete?
- kmp练习poj1961
- ffmpeg 教程之 rtmp 推送器
- 移动后台服务Bmob基础篇(一)
- 常用排序算法之冒泡排序
- linux c详解
- 剑指offer--面试题57:删除链表中重复的结点
- 链表中倒数第k个结点
- C3P0连接池+MySQL的配置以及wait_timeout问题的解决
- Android-Bug收集