|poj 2406|KMP|Power Strings
来源:互联网 发布:超级sql注入工具下载 编辑:程序博客网 时间:2024/05/18 03:48
poj传送门
可以知道,在一个字符串里的最短周期是
如果
#include<cstdio> #include<algorithm> #include<cstring> #define ms(i,j) memset(i,j, sizeof i); using namespace std;const int MAXN = 1000000 + 5;int n;char s[MAXN];int f[MAXN];int main() { while (scanf("%s", s)&&(s[0]!='.')) { n = strlen(s); f[0] = f[1] = 0; for (int i=1;i<n;i++) { int j = f[i]; while (j && s[i]!=s[j]) j = f[j]; f[i+1] = (s[i]==s[j]) ? (j+1) : (0); } int ans = n-f[n]; if (n%ans==0) ans = n/ans; else ans = 1; printf("%d\n", ans); } return 0; }
0 0
- poj 2406 Power Strings---kmp
- POJ 2406 Power Strings KMP
- poj-2406-Power Strings-kmp
- POJ-2406 Power Strings KMP
- Power Strings - POJ 2406 KMP
- poj 2406 Power Strings kmp
- POJ 2406-Power Strings (KMP)
- 【KMP】 POJ 2406 Power Strings
- poj 2406 Power Strings KMP
- POJ 2406 Power Strings KMP
- poj 2406 Power Strings KMP
- poj 2406 Power Strings (KMP)
- [2406]Power Strings (POJ) KMP
- Power Strings (poj 2406 KMP)
- poj 2406 Power Strings【KMP】
- POJ 2406 Power Strings(KMP)
- poj-2406 Power Strings 【kmp】
- POJ 2406--Power Strings【KMP】
- mysql启动时报 Bind on unix socket Address already in use的问题处理
- tips使用
- 外部看门狗驱动模块支持-max706s
- Android硬件抽象层(HAL)深入剖析(二)
- linux终端后台运行程序
- |poj 2406|KMP|Power Strings
- google chrome 插件开发
- Hadoop 2.6.3动态增加/删除DataNode节点
- 关于Android触摸事件的一些理解
- Mac版eclipse安装cvs插件
- 领域驱动设计系列文章(2)——浅析VO、DTO、DO、PO的概念、区别和用处
- JAVASCRIPT之禁止网页刷新
- skynet学习之环境变量skynet_env
- 关于CSS的垂直居中