原题链接: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. MYSQL存储过程调试过程

     mysql不像oracle有plsqldevelper工具用来调试存储过程,所以有几种简单的方式追踪执行过程: 1.用一张临时表,记录调试过程: 2.直接在存储过程中,增加select xxx,在控 ...

  2. 【Python进阶】用 Python 统计字数

    问题描述: 用 Python 实现函数 count_words(),该函数输入字符串 s 和数字 n,返回 s 中 n 个出现频率最高的单词.返回值是一个元组列表,包含出现次数最高的 n 个单词及其次 ...

  3. 使用经验风险最小化ERM方法来估计模型误差 开坑

    虽然已经学习了许多机器学习的方法,可只有我们必须知道何时何处使用哪种方法,才能将他们正确运用起来. 那不妨使用经验最小化ERM方法来估计 . 首先: 其中, δ代表训练出错的概率 k代表假设类的个数 ...

  4. 利用box-shadow制作loading图

    我们见过很多利用css3做的loading图,像下面这种应该是很常见的.通常制作这种loading,我们会一个标签对应一个圆,八个圆就要八个标签.但是这种做法很浪费资源.我们可以只用一个标签,然后利用 ...

  5. 2016-6-2-第二个sprint

    1.开始一个新的冲刺: 起止:2016.6.1~2016.6.14 ProductBacklog:继续向下细化 Sprint 计划会议:确定此次冲刺要完成的目标 Sprint Backlog:新的冲刺 ...

  6. 作业 20181030-3互评Alpha版本

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2323 组名:可以低头,但没必要 组长:付佳 组员:张俊余  李文涛  孙 ...

  7. 作业MathExamV2.0

    MathExam233 211614269 林凯 211601233张康凌 一.预估与实际 PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时( ...

  8. Centos 关闭图形界面

    查看/etc/inittab如下: # systemd uses 'targets' instead of runlevels. # by default, there are two main ta ...

  9. Alpha 冲刺6

    队名:日不落战队 安琪(队长) 今天完成的任务 回收站前端界面. 明天的计划 查看个人信息界面. 还剩下的任务 信息修改前端界面. 设置界面. 遇到的困难 模拟机莫名其妙就崩了,调试了很久,后在队友的 ...

  10. C#高级编程 (第六版) 学习 第五章:数组

    第五章 数组 1,简单数组 声明:int[] myArray; 初始化:myArray = new int[4]; 为数组分配内存. 还可以用如下的方法: int[] myArray = new in ...