Pagini recente » Borderou de evaluare (job #2019937) | Cod sursa (job #873585) | Cod sursa (job #1093245) | Cod sursa (job #1932513) | Cod sursa (job #1915424)
#include<bits/stdc++.h>
#define cheie 666013
#define dim 1000000
using namespace std;
long long n,x,sol,q;
int poz=0;
char buff[dim+5];
vector<long long> h[cheie+5];
void read(long long &nr)
{
nr=0LL;
while(buff[poz]<'0' || buff[poz]>'9')
{
poz++;
if(poz==dim)
{
poz=0;
fread(buff,1,dim,stdin);
}
}
while(buff[poz]>='0' && buff[poz]<='9')
{
nr=nr*10LL+1LL*(buff[poz]-'0');
poz++;
if(poz==dim)
{
poz=0;
fread(buff,1,dim,stdin);
}
}
}
void Add(long long x)
{
long long y=x%cheie;
for(vector<long long>::iterator it=h[cheie].begin();it!=h[cheie].end();it++)
{
if(*it==x) return;
}
h[cheie].push_back(x);
}
bool Find(long long x)
{
long long y=x%cheie;
for(vector<long long>::iterator it=h[cheie].begin();it!=h[cheie].end();it++)
{
if(*it==x) return 1;
}
return 0;
}
int main()
{
freopen("dtcsu.in","r",stdin);
freopen("dtcsu.out","w",stdout);
fread(buff,1,dim,stdin);
for(int i=1;i<=276997;i++)
{
read(x);
Add(x);
}
read(q);
for(int i=1;i<=q;i++)
{
read(x);
if(Find(x)) sol+=1LL;
}
printf("%lld\n",sol);
return 0;
}