随笔 - 386
文章 - 0
评论 - 21
阅读 -
21万
随笔分类 - 字符串————KMP
POJ 2406 Power Strings
摘要:http://poj.org/problem?id=2406题意 :求最小的重复子串的个数。思路 :KMP。#include #include #include using namespace std ;const int maxn = 10000000 ;char ch[maxn] ;int next[maxn] ;int main(){ while(scanf("%s",ch)!=EOF) { if(ch[0] == '.') break ; int len = strlen(ch) ; int i = 0 , j =...
阅读全文
POJ 1961 Period(KMP)
摘要:http://poj.org/problem?id=1961题意 :给你一个字符串,让你输出到第几个字符时,循环结的个数。思路 :这个题和2409差不多,稍微修改一下,加一个循环就行了,用的也是KMP。#include #include #include using namespace std ;const int maxn = 1000010 ;char ch[maxn] ;int next[maxn] ;int main(){ int n ; int test = 1 ; while(scanf("%d%*c",&n)!=EOF) { if(n == ...
阅读全文