题目传送门 Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24390   Accepted: 12723 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give…
The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time seek the fame. In order to escape from such boring job, t…
Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time seek the fame. In order to escape from such b…
题目链接 题意:求一个字符串中 前缀 和 后缀 相同的长度 分析: 对于一个字符串他自己的长度肯定是可以的.然后如果满足 前缀 和 后缀相等,那个前缀 最后一个字符 一定 和 该字符串最后一个字符相等,不然不会满足条件. 所以 找 str[len - 1] 的next数组, 对于 next[len - 1] 来看看这个位置 是不是等于最后一个字符,如果相等,那么前 next[len - 1] 一定是可以的, 然后 在判断next[ next[len - 1] ]  是不是等于 str[len -…
做此题,只要理解好next数组就行....................... #include <cstdio> #include <cmath> #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; char str[411111],tmp[411111]; int next[41111…
链接:http://poj.org/problem? id=2752 题意:对于一个字符串S,可能存在前n个字符等于后n个字符,从小到大输出这些n值. 思路:这道题加深了对next数组的理解.next[i+1]相当于以第i位结尾的长度为next[i+1]的子串与前next[i+1]个字符组成的子串同样.理解之后就比較好做了,首先字符串的长度len肯定是一个答案.然后next[len]也是一个答案,原因如红字所写,如此迭代直到next下标值等于0停止.这是从大到小得到了答案.再反序输出就可以. 由…
题意:给你一个字符串,寻找前缀和后缀相同的子串(包括原串). 从小到大排列输出其子串的长度 思路:KMP  next 数组应用. 其实就是一个数学推导过程. 首先由next数组 可知s(ab) = s(bd)   此时next[d]=b   而此时 next[b]=f,意味着s(ef)=s(gh) s(gh)属于s(ab)   s(ab)=s(bd);   所以可以推出 s(gh)属于s(bd)    且s(ef)=s(gh)  所以 s(ef)属于s(cd) #include<cstdio>…
题目链接:id=2752" style="color:rgb(202,0,0); text-decoration:none; font-family:Arial; font-size:18px; line-height:26px">http://poj.org/problem?id=2752 Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: …
Seek the Name, Seek the Fame Time Limit: 2000MS        Memory Limit: 65536K Total Submissions: 24000        Accepted: 12525 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to g…
题目链接:https://vjudge.net/problem/POJ-2752 Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 21220   Accepted: 11065 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland…