poj 2752 Seek the Name, Seek the Fame
来源:互联网 发布:中银淘宝信用卡怎么样 编辑:程序博客网 时间:2024/06/07 18:15
很基础的kmp题,只是需要将输出倒过来就行,于是用递归解决之。
#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int Maxn = 400010;char str[Maxn];int len, next[Maxn];bool flag;void get_next(){ int i = 0, j = -1; next[i] = j; while(i < len) { if(j == -1||str[i] == str[j]) { i++, j++; next[i] = j; } else j = next[j]; }}void out(){ int tmp; if(next[len] != -1) { tmp = next[len]; next[len] = next[next[len]]; flag = true; out(); } else return; if(tmp) cout<<tmp<<" ";}int main(void){ while(scanf("%s",str) != EOF) { len = strlen(str); get_next(); flag = false; out(); cout<<len<<endl; } return 0;}
0 0
- poj seek the name,seek the fame
- poj---Seek the Name, Seek the Fame
- Seek the Name, Seek the Fame POJ
- Seek the Name, Seek the Fame POJ
- POJ-2752 Seek the Name, Seek the Fame
- poj 2752 Seek the Name, Seek the Fame
- poj 2752 Seek the Name, Seek the Fame(KMP)
- POJ 2752--Seek the Name, Seek the Fame (next)
- POJ:2752Seek the Name, Seek the Fame
- POJ 2752 - Seek the Name, Seek the Fame
- poj 2752 Seek the Name, Seek the Fame
- poj 2752 Seek the Name, Seek the Fame
- POJ-2752-Seek the Name, Seek the Fame
- POJ 2752 Seek the Name, Seek the Fame
- poj 2752 Seek the Name, Seek the Fame
- poj 2752 Seek the Name, Seek the Fame
- POJ 2752 Seek the Name, Seek the Fame
- poj 2752 Seek the Name, Seek the Fame---kmp
- Shape组简介(翻译)
- OpenGLES - glBindTexture 绑定纹理缓存到纹理单元
- 第二篇、java入门之流程控制语句
- XCode学习随笔03--iOS界面-抽屉式交互
- 高并发系统数据库设计
- poj 2752 Seek the Name, Seek the Fame
- 大数类
- C标准重定向
- mysql中的存储引擎
- hive严格模式
- SSH 无需密码登录实现 SCP 信任
- 黑马程序员—AOP代理以及类似Spring的简单Aop框架
- 【c++】PAT (Advanced Level)1011. World Cup Betting (20)
- C语言经典算法100例-002-数轴的使用