HDU 1711 Number Sequence(kmp)】的更多相关文章

题目代号:HDU 1711 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711 Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 28288    Accepted Submission(s): 11891 Problem Description Give…
Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b[2], ...... , a[K + M - 1]…
白书说这个是MP,没有对f 数组优化过,所以说KMP有点不准确 #include <stdio.h> int a,b; int T[1000010],P[10010];//从0开始存 int f[10010];//记录P的自我匹配 void getFail(){ int m=b; f[0]=f[1]=0; for(int i=1;i<m;i++){ int j=f[i]; while(j&&P[i]!=P[j])j=f[j]; f[i+1]= P[i]==P[j] ? j…
HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) [Description] [题目描述] Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N…
Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 39408    Accepted Submission(s): 16269 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1],…
Number Sequence Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 90   Accepted Submission(s) : 57 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Given two sequences…
http://acm.hdu.edu.cn/showproblem.php?pid=1711 这道题就是一个KMP模板. #include<iostream> #include<cstring> using namespace std; +; int n,m; int next[maxn]; int a[maxn], b[maxn]; void get_next() { , j = ; ::next[] = -; while (j < m) { || b[i] == b[j]…
题意:裸kmp 思路:kmp模板 #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define MaxSize 10005 ],t[]; int next2[MaxSize]; void GetNext(int t[],int len){//求next数组 int j,k;//,len; j=; k=-; next2[]=-; //len=strlen(t); w…
我的第一道KMP. 把两个数列分别当成KMP算法中的模式串和目标串,这道题就变成了一个KMP算法模板题. #include<stdio.h> #include<string.h> #define N 1000005 #define M 10005 int a[N],b[M]; int next[M]; int n,m; void setNext() { int i,j; i=0; j=-1; next[i]=j; while(i<m) { if(j==-1||b[i]==b[…
这个就是kmp的数组形式,不用来处理字符串还真有点不习惯呢... #include<iostream> using namespace std; ,MAXM = ; int T[MAXN],P[MAXM],Next[MAXM]; void MakeNext(int M) { Next[] = -; , j = -; while(i<M) { ||P[i]==P[j]) { i++,j++; if(P[i]!=P[j])Next[i] = j; else Next[i] = Next[j]…