原题链接: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的更多相关文章

  1. 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的简单应 ...

  2. KMP POJ 2752 Seek the Name, Seek the Fame

    题目传送门 /* 题意:求出一个串的前缀与后缀相同的字串的长度 KMP:nex[]就有这样的性质,倒过来输出就行了 */ /************************************** ...

  3. POJ 2752 Seek the Name, Seek the Fame(求所有既是前缀又是后缀的子串长度)

    题目链接:http://poj.org/problem?id=2752 题意:给你一个字符串,求出所有前缀后缀(既是前缀又是后缀的子串)的长度 思路:首先整个字符串肯定既是前缀又是后缀,为最大的前缀后 ...

  4. hdu 1686 & poj 2406 & poj 2752 (KMP入门三弹连发)

    首先第一题 戳我穿越;http://acm.hdu.edu.cn/showproblem.php?pid=1686 题目大意好理解,每组输入一个子串和一个母串,问在母串中有多少个子串? 文明人不要暴力 ...

  5. (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 ...

  6. POJ 2752 Seek the Name, Seek the Fame(KMP求公共前后缀)

    题目链接:http://poj.org/problem?id=2752 题目大意:给你一串字符串s找到所有的公共前后缀,即既是前缀又是后缀的子串. 解题思路: 如图所示 假设字符串pi与jq为符合条件 ...

  7. 【kmp+求所有公共前后缀长度】poj 2752 Seek the Name, Seek the Fame

    http://poj.org/problem?id=2752 [题意] 给定一个字符串,求这个字符串的所有公共前后缀的长度,按从小到达输出 [思路] 利用kmp的next数组,最后加上这个字符串本身 ...

  8. POJ 2752 Seek the Name, Seek the Fame (KMP)

    传送门 http://poj.org/problem?id=2752 题目大意:求既是前缀又是后缀的前缀的可能的长度.. 同样是KMP,和 HDU 2594 Simpsons' Hidden Tale ...

  9. 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 ...

  10. POJ 2752 Seek the Name, Seek the Fame

    传送门 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14761   Accepted: 7407 Description ...

随机推荐

  1. Python Pygame(5)绘制基本图形

    最近很火一些简单图形构成的小游戏,这里介绍一些绘制图形的函数. 1.绘制矩形 rect(Surface,color,Rect,width=0) 第一个参数指定矩形绘制到哪个Surface对象上 第二个 ...

  2. Table Tennis Game 2(找规律)

    Description Misha and Vanya have played several table tennis sets. Each set consists of several serv ...

  3. tensorboard入门

    Tensorboard tensorboard用以图形化展示我们的代码结构和图形化训练误差等,辅助优化程序 tensorboard实际上是tensorflow机器学习框架下的一个工具,需要先安装ten ...

  4. OOP 2.1 类和对象的基本概念2

    1.成员函数的另一种写法:类的成员函数和类的定义分开写 e.g. class rectangle { public: int w,h; int area(); int p(); void init(i ...

  5. Windows Forms编程实战学习:第一章 初识Windows Forms

    初识Windows Forms 1,用C#编程 using System.Windows.Forms;   [assembly: System.Reflection.AssemblyVersion(& ...

  6. centos 6 编译emacs-24.5

    yum install `yum deplist emacs | grep provider | awk -F: '{print $2}' | awk '{print $1}' | xargs` yu ...

  7. 11月14号站立会议(从即日14号起到24号截至为final阶段工作期)

    小组名称:飞天小女警 项目名称:礼物挑选小工具 小组成员:沈柏杉(组长).程媛媛.杨钰宁.谭力铭 代码地址:HTTPS:https://git.coding.net/shenbaishan/GIFT. ...

  8. 虚拟机下安装CentOS6.5系统教程

    虚拟机下安装CentOS6.5系统教程 时间:2014-12-09 01:40来源:linuxdown.net 作者:linuxdown.net 举报 点击:15315次 其实通过VM安装虚拟机还是蛮 ...

  9. oracle锁与死锁概念,阻塞产生的原因以及解决方案

    锁是一种机制,一直存在:死锁是一种错误,尽量避免.​ 首先,要理解锁和死锁的概念:​ 1.锁: 定义:简单的说,锁是数据库为了保证数据的一致性而存在的一种机制,其他数据库一样有,只不过实现机制上可能大 ...

  10. Android内存泄漏第一课【转】--------(使用单例模式造成的内存泄漏)

    使用单例模式造成的内存泄漏 Android的单例模式在我们项目开发中经常会用到,不过使用的不恰当的话也会造成内存泄漏.因为单例的静态特性使得单例的生命周期和应用的生命周期一样长, 这就说明了如果一个对 ...