Create 5918.cpp

This commit is contained in:
Kirigaya Kazuto 2016-10-15 17:11:26 +08:00 committed by GitHub
parent 1e51053909
commit 1866f96fdd

36
HDOJ/5918.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define MAXN 100000
int a[MAXN];
int b[MAXN];
int main()
{
int t;
scanf("%d",&t);
for(int cc=1;cc<=t;cc++)
{
int n,m,p;
scanf("%d %d %d",&n,&m,&p);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(int i=0;i<m;i++) scanf("%d",&b[i]);
int qmax=n-(m-1)*p;
int c=0;
for(int q=1;q<=qmax;q++)
{
bool isok=true;
for(int j=0;j<m;j++)
{
if(a[q+j*p-1]!=b[j])
{
isok=false;
break;
}
}
if(isok) ++c;
}
printf("Case #%d: %d\n",cc,c);
}
return 0;
}