KMP UVA1328 Period
来源:互联网 发布:mac其他怎么清理 编辑:程序博客网 时间:2024/05/21 10:41
https://vjudge.net/problem/UVA-1328
KMP求循环节的问题
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 int n,l,j,cnt,et; 7 char s[1000010]; 8 int nt[1000010]; 9 int main(){ 10 while(scanf("%d",&n)==1&&n){11 scanf("%s",s+1);12 j=0;13 for(int i=2;i<=n;i++){14 while(j&&s[j+1]!=s[i]) j=nt[j];15 j+=(s[j+1]==s[i]);16 nt[i]=j;17 }18 printf("Test case #%d\n",++cnt);19 for(int i=2;i<=n;i++)20 if(nt[i]>0&&(i%(i-nt[i])==0)) printf("%d %d\n",i,i/(i-nt[i]));21 printf("\n");22 }23 return 0;24 }
阅读全文
0 0
- KMP UVA1328 Period
- uva1328 Period
- 【uva1328】Period
- 【UVA1328】Period
- KMP求前缀周期uva1328
- Period + KMP
- Period [KMP]
- period kmp
- Period kmp
- 1961 Period //KMP
- HDU 1358 Period (KMP)
- poj 1961:Period (KMP)
- zoj 2177 Period (KMP )
- (KMP)Period(H1358)
- 【KMP】 poj1961 Period
- poj1961 Period----KMP
- poj 1961 Period (KMP)
- Period hdu1358 KMP
- Python编程_Lesson003_字符串
- 贪心 NOIP2013 花匠
- 单调队列 BZOJ 2096 [Poi2010]Pilots
- KMP POJ 2752Seek the Name, Seek the Fame
- 动态规划入门 BZOJ 1270 雷涛的小猫
- KMP UVA1328 Period
- 树形DP 洛谷P2014 选课
- 倍增LCA NOIP2013 货车运输
- 快速幂 NOIP2013 转圈游戏
- 贪心 NOIP2013 积木大赛
- 贪心 洛谷P2870 Best Cow Line, Gold
- 二分图 洛谷P2055 [ZJOI2009]假期的宿舍
- 动态规划入门 洛谷P1108 低价购买
- 状压DP 洛谷P2704 炮兵阵地