码迷,mamicode.com
首页 >  
搜索关键字:循环节    ( 617个结果
HDOJ1358 Period (KMP next数组应用)
题意:n个字符的字符串,从第二个字符开始遍历。如果从第一个字符到当前字符是有循环的,那么输出当前的位置和最大循环次数。两组数据之间输出一个空格。 所以我们需要先解决如何算出(1...x)串的最大循环次数,再遍历就ok 所以如何找到最小循环节,如果(1...x)有循环x-next[x]就是循环节,可以在纸上画画,从前往后可以用“1...x-next[x]”这串字符推出整个串。而且这是最小循环节,...
分类:编程语言   时间:2015-02-17 22:24:27    阅读次数:218
【KMP】Period
KMP算法Next[]函数深入理解,Next[]当前字符前匹配字符数,串长n-Next[i]=串内循环子串的长度p。本题求子循环串内循环节数。Problem DescriptionFor each prefix of a given string S with N characters (each ...
分类:其他好文   时间:2015-02-15 16:25:23    阅读次数:137
ZOJ 2105 Number Sequence(矩阵快速幂)
题意: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. 给定A,B,求f(n)。 法一:          网上较多的题解都提到了寻找1 1循环节的方法,的确非常巧妙,每位0~6,共7种可能,相邻两位共49种可能,因此循环周期至多为49,一旦出现相同数对,那么其后必相同。但是,该方法只是简单提及了49,却并...
分类:其他好文   时间:2015-02-09 18:27:36    阅读次数:147
poj2406--Power Strings+KMP求周期
先把结论摆出来:对于长为j的字符串str[1..j],next[j]=k,则令d=j-k;如果j%d==0,则这个字符串是一个 周期串,前d个字符是其最小的循环结,共包含j/d个循环节。 现在来解决两个问题: 1)前d个字符是其循环结         下标  1   2  3  4  5  6  7  8        字符串 a   b  a  b  a  b  a  b   ...
分类:其他好文   时间:2015-02-07 17:35:30    阅读次数:145
杭电ACM 找循环节 std::ios::sync_with_stdio(false);
Problem Description As a unicorn, the ability of using magic is the distinguishing feature among other kind of pony. Being familiar with composition and decomposition is the fundamental course ...
分类:移动开发   时间:2015-02-06 21:52:01    阅读次数:226
POJ 1961 Period (KMP)
解题思路:  利用next 数组的性质求解重复子串。循环节的长度为i - next[i]; #include #include #include #include #include #include #include using namespace std; const int maxn = 1000000 + 10; char s[maxn]; int n; int next[...
分类:其他好文   时间:2015-02-01 19:12:28    阅读次数:186
POJ2406 Power Strings next数组应用
题目描述: 给定一个字符串,求其最大循环次数(即求最小循环节长度) 输入样例 abcd ababab aaaa . 输出样例 1 3 4 解题思路: KMP算法中next数组的应用。 len-next[len]表示的是字符串相同前缀空出来的一段,由next数组性质可知,这一段可以不断向前推出相等,所以只要判断len是否可以整除len-next[len]就可以了。否...
分类:编程语言   时间:2015-01-30 16:11:23    阅读次数:311
YT14-HDU-找循环节 (关于std::ios::sync_with_stdio(false);的作用和疑问)
Problem Description As a unicorn, the ability of using magic is the distinguishing feature among other kind of pony. Being familiar with composition and decomposition is the fundamental course ...
分类:移动开发   时间:2015-01-29 12:52:16    阅读次数:161
寻找不是开头的循环节
#include int f[1010]= {0, 1, 1};int main(){ int a, b; long long int n; while( ~scanf("%d%d%lld", &a, &b, &n) && a+b+n) { for(int i=3; i<=n; i++) //两个循...
分类:其他好文   时间:2015-01-29 12:05:18    阅读次数:200
poj1026--Cipher
题意:看着样例说吧     给你n个数字a[i](>0&&如果字符串长度小于n,后面补为空格;然后进行交换:之前字符串的位置i对应的 a[i]位置就是交换一次后的字符位置,问交换k次后的字符串;            分析:单纯模拟会超时,这其中有个规律:对于一个字符,交换某些次之后,就会变回原来的(即会循环),只需找出它的循环周期T,交换k%T次就可; #include #include...
分类:其他好文   时间:2015-01-28 13:07:18    阅读次数:154
617条   上一页 1 ... 48 49 50 51 52 ... 62 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!