HDU1711-KMP-水题】的更多相关文章

题意:定义一个a*b=字符串a连接字符串b:给你一个字符串s,问你这个字符串最多能用多少个字符串t连接得到:例如:aaaa=4个a构成: 解题思路:kmp水题,next数组除了查找字串以外最广泛的一种用法,用来判定一个串是不是循环串,如果是,输出原串的长度/最小的循环节,否则,输出1就行了: 代码: #include<iostream> #include<cstdio> #include<cstring> #define maxn 1000500 using names…
http://poj.org/problem?id=3461 直接KMP就好.水题 #include<cstdio> #include<cstring> const int MAXN=10000+10; const int MAXM=1000000+10; char P[MAXN],T[MAXM]; int f[MAXN],n,m,ans; void getFail() { f[0]=f[1]=0; for(int i=1;i<n;i++){ int j = f[i]; wh…
Theme Section Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 574    Accepted Submission(s): 308 Problem Description It's time for music! A lot of popular musicians are invited to join us in th…
Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 17971    Accepted Submission(s): 7854 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b…
题意:求最长的a的前缀同时满足是b的后缀,把a,b连在一起,kmp跑一下,迭代next直到长度小于等于a,b长度的最小值为止,即为答案. #pragma comment(linker, "/STACK:10240000,10240000") #include <iostream> #include <cstdio> #include <algorithm> #include <cstdlib> #include <cstring&g…
题意:求模板串在文本串中出现的次数(位置无交叉).只需在找到的时候把模板串指针归0即可. #pragma comment(linker, "/STACK:10240000,10240000") #include <iostream> #include <cstdio> #include <algorithm> #include <cstdlib> #include <cstring> #include <map>…
循环移位的套路操作就是一份折开变两份 /*H E A D*/ void match(){ int n=strlen(T+1); int m=strlen(P+1); int j=0; rep(i,1,n){ if(flag)break; while(j>0&&(j==m||T[i]!=P[j+1])) j=nxt[j]; if(T[i]==P[j+1]) j++; f[i]=j; if(f[i]==m){ flag=1; break; } } } int main(){ while(…
D - 楼下水题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1258 Description A string is said to be a palindrome if it remains same when read backwards. So, 'abba', 'madam' both are palindromes,…
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意"和"解题思路"外, 新增"Source修正",因为原Source较模糊,这是为了帮助某些狂WA的同学找到测试数据库,但是我不希望大家利用测试数据打表刷题 ­­ ­ 推荐文:1.一位ACMer过来人的心得 2. POJ测试数据合集 OJ上的一些水题(可用来练手和增…
In computer science, the Knuth-Morris-Pratt string searching algorithm (or KMP algorithm) searches for occurrences of a "word" W within a main "text string" S by employing the observation that when a mismatch occurs, the word itself em…