poj1961---KMP
来源:互联网 发布:图片尺寸修改软件 编辑:程序博客网 时间:2024/06/15 21:35
//和poj2406同样处理//一个失败函数就行//因为s=a^n,所以如果i%(i-f[i])==0,那么其a的长度就是i-f[i]了#include <iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define N 1000005int n,m,t,p,end;char str[N];int f[N];int main(){ end++; while(scanf("%d",&n),n) { scanf("%s",str); int i,j,k; f[0]=j=-1,i=0; while(i<n) { if(j==-1||str[i]==str[j]) { ++i,++j; f[i]=j; } else j=f[j]; } printf("Test case #%d\n",end++); for(i=2;i<=n;i++) { if(i%(i-f[i])==0&&i/(i-f[i])!=1) { printf("%d %d\n",i,i/(i-f[i])); } } puts(""); } return 0;}
- 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)
- kmp练习poj1961
- POJ1961 Period(KMP)
- kmp算法 和例题 poj1961
- poj1961 KMP求循环节
- POJ1961(KMP-Next数组)
- poj1961 KMP(循环节)
- Oracle 函数 与 存储过程 的应用
- 最短路径之Floyd—Warshall算法
- Android的事件处理机制和滑动
- hadoop伪分布式运行wordcount 实例Fedora14
- zoj 1152 A Mathematical Curiosity
- poj1961---KMP
- 屏蔽JS错误和右键
- 学习
- C++中将科学计数转换为其他类型
- 经典JavaScript特效
- Intent
- Oralce 函数表达式 的应用
- poj 1157 LITTLE SHOP OF FLOWERS
- WAMP转移至LNMP平台遇到的几个问题及解决方法