http://codeforces.com/contest/1016/problem/B
题意:给定两个字符串,若干次询问,问在询问区间内,a中有多少个b
(也可用kmp写)
打表
#include <bits/stdc++.h>
using namespace std;
int a[1100];
int main()
{
int n,m,k,q,l,r,ans;
memset(a,0,sizeof(a));
string s,t;
cin >> n >> m >> q;
cin >> s >> t;
for (int i = 0; i <= n-m; i ++)
if (s.substr(i,m) == t)
a[i] = 1;
while (q --) {
ans = 0;
cin >> r >> l;
for (int i = r-1; i <= l-m; i ++)
if (a[i])
ans ++;
cout << ans << endl;
}
return 0;
}