POJ--2752
原题链接:http://poj.org/problem?id=2752
分析:no!
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 400005
using namespace std;
char s[maxn];
int len,next[maxn],ans[maxn];
void get_next()
{
int i=,j=-;len=strlen(s);
next[]=-;
while(i<len){
if(j==-||s[i]==s[j]){
i++;j++;
next[i]=j;
}
else j=next[j];
}
}
int main()
{
while(gets(s))
{
get_next();
int num=,j=len;
while(j){
ans[num++]=j;
j=next[j];
}
for(j=num-;j>=;j--)
printf("%d ",ans[j]);
printf("%d\n",ans[]);
}
return ;
}
POJ--2752的更多相关文章
- Seek the Name, Seek the Fame POJ - 2752
Seek the Name, Seek the Fame POJ - 2752 http://972169909-qq-com.iteye.com/blog/1071548 (kmp的next的简单应 ...
- KMP POJ 2752 Seek the Name, Seek the Fame
题目传送门 /* 题意:求出一个串的前缀与后缀相同的字串的长度 KMP:nex[]就有这样的性质,倒过来输出就行了 */ /************************************** ...
- POJ 2752 Seek the Name, Seek the Fame(求所有既是前缀又是后缀的子串长度)
题目链接:http://poj.org/problem?id=2752 题意:给你一个字符串,求出所有前缀后缀(既是前缀又是后缀的子串)的长度 思路:首先整个字符串肯定既是前缀又是后缀,为最大的前缀后 ...
- hdu 1686 & poj 2406 & poj 2752 (KMP入门三弹连发)
首先第一题 戳我穿越;http://acm.hdu.edu.cn/showproblem.php?pid=1686 题目大意好理解,每组输入一个子串和一个母串,问在母串中有多少个子串? 文明人不要暴力 ...
- (KMP)Seek the Name, Seek the Fame -- poj --2752
http://poj.org/problem?id=2752 Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536 ...
- POJ 2752 Seek the Name, Seek the Fame(KMP求公共前后缀)
题目链接:http://poj.org/problem?id=2752 题目大意:给你一串字符串s找到所有的公共前后缀,即既是前缀又是后缀的子串. 解题思路: 如图所示 假设字符串pi与jq为符合条件 ...
- 【kmp+求所有公共前后缀长度】poj 2752 Seek the Name, Seek the Fame
http://poj.org/problem?id=2752 [题意] 给定一个字符串,求这个字符串的所有公共前后缀的长度,按从小到达输出 [思路] 利用kmp的next数组,最后加上这个字符串本身 ...
- POJ 2752 Seek the Name, Seek the Fame (KMP)
传送门 http://poj.org/problem?id=2752 题目大意:求既是前缀又是后缀的前缀的可能的长度.. 同样是KMP,和 HDU 2594 Simpsons' Hidden Tale ...
- POJ 2752 Seek the Name, Seek the Fame [kmp]
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
- POJ 2752 Seek the Name, Seek the Fame
传送门 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14761 Accepted: 7407 Description ...
随机推荐
- Hibernate查询的六种方式
Hibernate查询的六种方式 分别是HQL查询,对象化查询Criteria方法,动态查询DetachedCriteria,例子查询,sql查询,命名查询. 如果单纯的使用hibernate ...
- 第四周 实验一 Java开发环境的熟悉 报告
Java开发环境的熟悉 实验内容 1.IDEA的安装过程 2.使用IDEA代替虚拟机运行.编译.调试Java程序 实验要求 1.没有Linux基础的同学建议先学习<Linux基础入门(新版)&g ...
- MacOS下搭建python环境
1. 安装须知 Mac OS自身其实已经带有Python,版本为2.7.X,这个Python主要用于支持系统文件和XCode,所以我们在安装新的Python版本时候最好不要影响这部分. 这里就会出现一 ...
- wamp上能够访问jsp(未解决 游客勿看)
Windows下使用apache的jk_mod连接WAMP和Tomcat 发表于 2013 年 4 月 29 日 由 www.tonitech.com的站长 | 暂无评论 | Apache,Windo ...
- 图论---POJ 3660 floyd 算法(模板题)
是一道floyd变形的题目.题目让确定有几个人的位置是确定的,如果一个点有x个点能到达此点,从该点出发能到达y个点,若x+y=n-1,则该点的位置是确定的.用floyd算发出每两个点之间的距离,最后统 ...
- HDU 5265 pog loves szh II 二分
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5265 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- Ubuntu系统升级内核方法
一.查看内核版本 $ uname-sr //查看内核版本 二.去Ubuntu网站http://kernel.ubuntu.com/~kernel-ppa/mainline/下载所需版本的deb文件 w ...
- 单机安装 consul ui 对外提供服务
Consul 安装启动ui,外网无法访问,应为Consul 默认绑定127.0.0.1 ,所以外网无法访问. 通过设置 -client 参数来设置 consul agent -server - ...
- jQuery的2把利器
<!-- $是一个函数,首先是给window添加$,然后该值是一个函数,函数返回的值是对象.1. jQuery核心函数 * 简称: jQuery函数($/jQuery) * jQuery库向外直 ...
- CCF——门禁系统201412-1
问题描述 涛涛最近要负责图书馆的管理工作,需要记录下每天读者的到访情况.每位读者有一个编号,每条记录用读者的编号来表示.给出读者的来访记录,请问每一条记录中的读者是第几次出现. 输入格式 输入的第一行 ...