Period II】的更多相关文章

http://acm.fzu.edu.cn/problem.php?pid=1901 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=70325#problem/Q Period II Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice FZU 1901 Description For ea…
题目链接:https://vjudge.net/problem/FZU-1901  Problem 1901 Period II Accept: 575    Submit: 1495Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description For each prefix with length P of a given string S,if S[i]=S[i+P] for i in [0..SIZE(S)-p-…
题目链接: Problem 1901 Period II 题目描述: 给出一个串,满足长度为p的前缀和长度为p的后缀相等的p的个数,输出p的个数,和p分别是多少? 解题思路: 对kmp的next数组的理解程度,next[i] = j的时候,就是当子串匹配到i的时候失配,就回溯到j的位置从新匹配,(s[0, j] == s[i-j, i]) 对于next[len] = x, s[0, x] == s[len-x, len]. next[x] = y, s[0, y] == s[x - y, x];…
Problem Description For each prefix with length P of a given string S,if S[i]=S[i+P] for i in [0..SIZE(S)-p-1], then the prefix is a “period” of S. We want to all the periodic prefixs.  Input Input contains multiple cases. The first line contains an…
For each prefix with length P of a given string S,if S[i]=S[i+P] for i in [0..SIZE(S)-p-1], then the prefix is a “period” of S. We want to all the periodic prefixs. Input Input contains multiple cases. The first line contains an integer T representin…
For each prefix with length P of a given string S,if S[i]=S[i+P] for i in [0..SIZE(S)-p-1], then the prefix is a “period” of S. We want to all the periodic prefixs. Input Input contains multiple cases. The first line contains an integer T representin…
For each prefix with length P of a given string S,if S[i]=S[i+P] for i in [0..SIZE(S)-p-1], then the prefix is a “period” of S. We want to all the periodic prefixs. Input Input contains multiple cases. The first line contains an integer T representin…
题目大意:给你一个字符串 S ,N = |S|,如果存在一个 P (1<=P<=N),并且满足 s[i] = s[P+i] (i = {0...N-P-1} ),求出来所有的 P 然后输出.   分析:其实就是这个字符串的后缀与前缀的最大匹配 next[N],然后用最大匹配的串继续找匹配的前缀,比如下面的数据:   aaabaaa:--> P = 4  <---> next[7] = 3 aaabaaa:--> P = 5  <---> next[3] =…
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1901 题目大意:题目大意求出所有p满足s[i]=s[i+p](i<=len-p) 解题思路: 其实就是要找出所有的循环节(不只是最小的),循环节本质跟公共前后缀有关,可以通过递归的方法求出所有公共前后缀ti,那么len-ti就是相应循环节. 之前写的计算最小循环节,累加循环节得到前缀的方法是有问题的,过不了下面这种数据.数据:abacaba结果应该是4,6,7而求出来的是4,7.因为忽略了除了最小循环节外的…
题意:给你一串字符串,问你前后缀相同情况有几种,并输出后缀位置(?这里一直没看懂length是什么,但是这样理解答案也对,然后还要加上本身长度) 思路:这里好好讲讲next的用法.我们都知道next代表前后缀匹配值,现在我们以下面这个字符串为例,讲述next的用法: len = 9,next[len] = 4,所我们找到了第一个前后缀匹配串abab,next[ next[len] ] = next[4] = 2,所以第二个前后缀匹配串长度为2.因为next[len] = 4,所以s[0...3]…