POJ 2406 KMP
来源:互联网 发布:java图形程序设计 编辑:程序博客网 时间:2024/06/03 20:24
//poj 2406 求字符串的最小循环节,输出重复次数#include<iostream>#include<cstdio>#include<cstdlib>#include<algorithm>#include<string.h>#define maxn 5000000using namespace std;int next[maxn];char s[maxn];//研究getnext函数的原理。暂时理解不出来。void getnext(){ int len=strlen(s); int i=0;int j=-1; next[0]=-1; while(i<len) { if(s[i]==s[j] || j==-1) { i++; j++; next[i]=j; } else { j=next[j]; } }}int main(){ while(scanf("%s",s)!=EOF) { if(s[0]=='.') break; getnext(); int len=strlen(s); if(len%(len-next[len])==0) printf("%d\n",len/(len-next[len])); else printf("%d\n",1); }}
0 0
- poj 2406 KMP
- POJ 2406 KMP
- 【KMP】POJ 2406
- poj 2406 KMP应用
- POJ 2406 (KMP)
- POJ 2406 kmp
- poj 2406 KMP算法
- poj 2406 kmp
- poj 2406(kmp)
- POJ 2406 KMP
- POJ 2406 依然 KMP
- poj 2406 KMP
- POJ-2406(KMP)
- POJ 2406 KMP
- POJ 2406 (KMP)
- POJ 2406 KMP
- 字符串 KMP POJ 2406
- POJ 2406(kmp)
- jar -help
- HDU 4455 线段树
- android学习笔记 内容提供者
- 用类加载器的方式管理资源和配置文件
- xUtils系列之DbUtils-增,删,更新,替换操作
- POJ 2406 KMP
- cf-538B Quasi Binary【贪心】
- POJ 2823 单调队列
- POJ 3321 树状数组
- UML简单介绍(二)——UML中的图及其特征
- POJ 3461 KMP
- JAR WAR EAR包的区别
- e5-5uva12096
- Restful 406 Not Acceptable