Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative inte…
Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 30069   Accepted: 12553 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "…
Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 37685   Accepted: 15590 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "…
题目链接:http://poj.org/problem?id=2406 题意:给出一个字符串s,求重复子串出现的最大次数. 分析:kmp的next[]数组的应用. 要求重复子串出现的最大次数,其实就是求字符串的最小循环节. 以下内容转载于:http://bbezxcy.iteye.com/blog/1377787 --------------------------------------------------------------------------------------------…
Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative inte…
题目链接:http://poj.org/problem?id=2406 题目大意:如果n%(n-next[n])==0,则存在重复连续子串,长度为n-next[n]. 例如:      a    b    a    b    a    b next:-1   0    0    1    2    3    4 next[n]==4,代表着,前缀abab与后缀abab相等的最长长度,这说明,ab这两个字母为一个循环节,长度=n-next[n]; #include <iostream> #inc…
题目链接:http://poj.org/problem?id=2406 题意:就是求一个字符串最多有几个相同的小字符串组成. 题解:直接求一下next然后找到长度,长度就是len-1-next[len-1]. #include <iostream> #include <cstring> using namespace std; const int M = 1e6 + 10; char s[M] , p[M]; int Next[M]; void getnext() { int le…
题意:重复子串次数 思路:kmp #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define MaxSize 1000005 int next[MaxSize]; void GetNext(char t[]){//求next数组 int j,k,len; j=; k=-; next[]=-; len=strlen(t); while(j<len){ ||t…
kmp,根据next数组的性质如果有答案的话就是n/(n-(ne[n]+1)),否则是1 搬来打算用SA后来发现必须用DC3就没写 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=1000005; int n,ne[N]; char s[N]; int main() { while(scanf("%s",s)&&…
题目传送门 /* 题意:一个串有字串重复n次产生,求最大的n KMP:nex[]的性质应用,感觉对nex加深了理解 */ /************************************************ * Author :Running_Time * Created Time :2015-8-10 10:51:54 * File Name :POJ_2406.cpp ************************************************/ #incl…