Pagini recente » Cod sursa (job #813191) | Cod sursa (job #1635127) | Cod sursa (job #801297) | Cod sursa (job #3180100) | Cod sursa (job #3177484)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");
#define HASH_BASE 264
#define HASH_SIZE1 1007
int computehash(ll x)
{
return x % HASH_SIZE1;
}
vector<int> hashvalues[1008];
void addhash(ll x)
{
int numhash = computehash(x);
int i=0;
while(i<(int)hashvalues[numhash].size() && hashvalues[numhash][i]!=x)
{
i++;
}
if(i==(int)hashvalues[numhash].size())
{
hashvalues[numhash].push_back(x);
}
}
int query(ll x)
{
int numhash = computehash(x);
int i=0;
while(i<(int)hashvalues[numhash].size() && hashvalues[numhash][i]!=x)
{
i++;
}
if(i < (int)hashvalues[numhash].size())
{
return 1;
}
return 0;
}
int main()
{
for(int i=1;i<=276997;i++)
{
ll x;
fin >> x;
addhash(x);
}
int q;
fin >> q;
int cnt=0;
while(q--)
{
int x;
fin >> x;
cnt += query(x);
}
fout << cnt;
}