POJ 1961】的更多相关文章

关于KMP的最短循环节.循环周期,请戳: http://www.cnblogs.com/chenxiwenruo/p/3546457.html (KMP模板,最小循环节) POJ 2406  Power Strings 题意:给一个字符串,问这个字符串是否能由另一个字符串重复R次得到,求R的最大值. #include <iostream> #include <stdio.h> #include <string.h> /* 题意: 给一个字符串,问这个字符串是否能由另一个…
题目传送门 /* 题意:求一个串重复出现(>1)的位置 KMP:这简直和POJ_2406没啥区别 */ /************************************************ * Author :Running_Time * Created Time :2015-8-10 9:13:24 * File Name :POJ_1961.cpp ************************************************/ #include <cstd…
Period POJ - 1961 时限: 3000MS   内存: 30000KB   64位IO格式: %I64d & %I64u 提交 状态 已开启划词翻译 问题描述 For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a per…
http://poj.org/problem?id=1961 题意 :给你一个字符串,让你输出到第几个字符时,循环结的个数. 思路 :这个题和2409差不多,稍微修改一下,加一个循环就行了,用的也是KMP. #include <string.h> #include <stdio.h> #include <iostream> using namespace std ; ; char ch[maxn] ; int next[maxn] ; int main() { int…
题目: http://poj.org/problem?id=1961 很好的题,但是不容易理解. 因为当kmp失配时,i = next[i],所以错位部分就是i - next[i],当s[0]...s[i]是一个周期串时,i-next[i]显然就是一个循环节,这时(i+1) % (i-next[i]) == 0,(因为下标是从0开始的,所以i+1表示前i个字符,也就是字符个数),判断上式是否为0就可以判断是否是周期串,如果是周期串时,(i+1) / (i-next[i]) 显然就是重复的次数.…
Period http://poj.org/problem?id=1961 Time Limit: 3000MS   Memory Limit: 30000K       Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the pref…
题目地址:http://poj.org/problem?id=1961 Sample Input 3 aaa 12 aabaabaabaab 0 Sample Output Test case #1 2 2 3 3 Test case #2 2 2 6 2 9 3 12 4 题目分析:给你一个字符串,最大长度1百万.输出是:以第1组样例解释,在aaa的字符串中,长度为2时,存在2个循环节a.当长度为3时,存在3个循环节a.以第二组样例解释,当长度为2时,存在2个循环节a.当长度为6时,存在2个循…
Period Time Limit: 3000MSMemory Limit: 30000K Total Submissions: 12089Accepted: 5656 Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefi…
Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 <= i <= N) we want to know the larges…
和POJ 2406 几乎一样.前者是求 该字符串的最小的循环节.也就是最大的循环次数.后者是求该字符串的每个前缀的循环节的最大循环次数.(如果有的话).而且必须大于1.才可以输出.就是POJ 2406变形.加一个循环遍历就可以了.当然了.结论仍然是我[记住]的. #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> using namespace std…