[HDU 1358]Period[kmp求周期]
来源:互联网 发布:h5界面源码 编辑:程序博客网 时间:2024/06/06 08:25
题意:
每一个power前缀的周期数(>1).
思路:
kmp的next. 每一个前缀都询问一遍.
#include <cstring>#include <cstdio>const int MAXN = 1000005;int next[MAXN];char s[MAXN];//93MS5092Kvoid prekmp(){ next[0] = -1; int j = -1; for(int i=1;s[i];i++) { while(j!=-1 && s[j+1]!=s[i]) j = next[j]; if(s[j+1]==s[i]) j++; next[i] = j; }}int main(){ int n,cas = 0; while(scanf("%d",&n) && n) { scanf("%s",s); printf("Test case #%d\n",++cas); prekmp(); int len; for(int i=1;i<n;i++) { len = i-next[i]; int k; if(!((i+1)%len)) { if((k=(i+1)/len)>1) printf("%d %d\n",i+1,k); } } printf("\n"); }}
- HDU 1358 Period(KMP求周期)
- [HDU 1358]Period[kmp求周期]
- HDU 1358 Period (kmp求周期)
- HDU 1358 Period 求周期串(kmp)
- HDU 1358Period(KMP周期串)
- hdu-1358 period(求周期串)
- hdu 1358 period 求循环节 KMP
- HDU-1358 Period(KMP求循环节)
- poj 1961 Period(KMP求周期)
- HDU 1358 Period (KMP)
- HDU 1358 Period KMP
- hdu 1358 Period KMP
- hdu 1358 Period(KMP)
- HDU 1358 Period KMP
- 【HDU】1358 Period KMP
- HDU 1358 Period (KMP)
- hdu-1358 Period 【kmp】
- hdu 1358 Period ( kmp )
- Integer与int解惑
- Working Practice-要熟练使用常用的工具
- struct的三种初始化方法
- javascrip 类,location对象用法
- Python中执行系统命令常见的几种方法
- [HDU 1358]Period[kmp求周期]
- 浅析远程过程调用 RPC
- Windows Embedded 8.1 Industry 的新增功能
- 从零开始学习jQuery (二) 万能的选择器
- 质量管理术语解释
- 好玩的笔试题
- Add custom and listview web part to wiki page using powershell
- 装系统那些事儿-1-电脑的启动流程
- 在Ubuntu上安装GNOME 3.8