摘要:
例如:6 a b a b a b ‘\0’下标i: 0 1 2 3 4 5 6Next: -1 0 0 1 2 3 4dp: 0 1 1 2 2 3 3dp[ 1 ]=1表示目前:‘a’出现一次dp[ 2 ]=1:同上:“ab”dp[ 3 ]=2表示“abab”一次,“ab”一次。。。dp[ 6 ]=3表示首字母‘a’在整个的出现次数KMP够强大!!!!!View Code 1 #include<stdio.h> 2 #include<string.h> 3 const int maxn = 200005; 4 const int mod= 10007; 5 char 阅读全文
posted @ 2013-02-03 15:53
xxx0624
阅读(261)
评论(0)
推荐(0)
摘要:
题意:一个字符串在另一个字符串中出现的次数View Code 1 #include<stdio.h> 2 #include<string.h> 3 const int maxn = 10005; 4 const int maxm= 1000005; 5 int lena,lenb; 6 char a[ maxm ],b[ maxn ]; 7 int next[ maxn ]; 8 int ans; 9 void getNext(){10 int j,k;11 j=0,k=-1;12 next[0]=-1;13 while( j<lenb ){14 ... 阅读全文
posted @ 2013-02-03 00:02
xxx0624
阅读(277)
评论(0)
推荐(0)