poj 2406 Power Strings(kmp应用)】的更多相关文章

Power Strings Time Limit: 3000MSMemory Limit: 65536K Total Submissions: 29663Accepted: 12387 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…
http://poj.org/problem?id=2406 Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 27003   Accepted: 11311 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = &q…
点击打开链接 Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 27368   Accepted: 11454 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: 28102   Accepted: 11755 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 Time Limit: 3000MS Memory Limit: 65536K 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 thi…
传送门 http://poj.org/problem?id=2406 题目就是求循环了几次. 记得如果每循环输出为1.... #include<cstdio> #include<cstring> const int MAXN=1000000+10; char P[MAXN]; int f[MAXN]; int n,m; void getFail() { int i,j; f[0]=f[1]=0; for(i=1;i<n;i++) { j=f[i]; while(j &…
本题是计算一个字符串能完整分成多少一模一样的子字符串. 原来是使用KMP的next数组计算出来的,一直都认为是能够利用next数组的.可是自己想了非常久没能这么简洁地总结出来,也仅仅能查查他人代码才恍然大悟,原来能够这么简单地区求一个周期字符串的最小周期的. 有某些大牛建议说不应该參考代码或者解题报告,可是这些大牛却没有给出更加有效的学习方法,比方不懂KMP.难倒不应该去看?要自己想出KMP来吗?我看不太可能有哪位大牛能够直接自己"又一次创造出KMP"来吧. 好吧.不说"创造…
题意:给一个字符串,求该串最多由多少个相同的子串相接而成. 思路:只要做过poj 1961之后,这道题就很简单了.poj 1961 详细题解传送门. 假设字符串的长度为len,如果 len % (len - next[len])不为0,说明该字符串不能由其他更短的字符串反复相接而成,结果输出1,否则答案为len / (len - next[len]). #include<stdio.h> #include<string.h> #define maxn 1000010 char s[…
对于数组s[0~n-1],计算next[0~n](多计算一位). 考虑next[n],如果t=n-next[n],如果n%t==0,则t就是问题的解,否则解为1. 这样考虑: 比方字符串"abababab", a  b a b a b a b * next     -1 0 1 2 3 4 5 6  7 考虑这种模式匹配,将"abababab#"当做主串."abababab*"当做模式串.于是进行匹配到n(n=8)时,出现了不匹配: 主串    …
题目传送门 /* 题意:一个串有字串重复n次产生,求最大的n KMP:nex[]的性质应用,感觉对nex加深了理解 */ /************************************************ * Author :Running_Time * Created Time :2015-8-10 10:51:54 * File Name :POJ_2406.cpp ************************************************/ #incl…