#include<iostream>
#include<utility>
#include<cstring>
#include<cstdio>
using namespace std;
typedef unsigned long long ull;
const int b=101,M=1e6+9;
char s1[M],s2[M];
ull s,sum[M],power[M];
int main(){
int i,l1,l2,ans,kase;
scanf("%d\n",&kase);
power[0]=1;
for(i=1;i<1000000;i++)
power[i]=power[i-1]*b;
while(kase--){
scanf("%s%s",s1+1,s2+1);
int l1=strlen(s1+1),l2=strlen(s2+1);
sum[0]=0;
for(i=1;i<=l2;i++)
sum[i]=sum[i-1]*b+(ull)(s2[i]-'A');
s=0;
for(i=1;i<=l1;i++)
s=s*b+(ull)(s1[i]-'A');
ans=0;
for(i=0;i<=l2-l1;i++)
if(s==sum[i+l1]-sum[i]*power[l1])
ans++;
printf("%d\n",ans);
}
return 0;
}
HDU 1696
最新推荐文章于 2020-03-06 15:50:35 发布