Pagini recente » Cod sursa (job #1230581) | Cod sursa (job #303300) | Cod sursa (job #1326771) | Cod sursa (job #377295) | Cod sursa (job #2305616)
#include <cstdio>
#include <cctype>
#include <vector>
#define BUFF_SIZE (1<<10)
char buff[BUFF_SIZE];
int poz=BUFF_SIZE;
char GetChar(){
if(poz==BUFF_SIZE){
fread(buff,1,BUFF_SIZE,stdin);
poz=0;
}
return buff[poz++];
}
long long GetInt(){
long long n=0;
char c;
do{
c=GetChar();
}while(!isdigit(c));
do{
n=n*10+c-'0';
c=GetChar();
}while(isdigit(c));
return n;
}
#define MOD 86243
struct HashInt{
std::vector<long long> H[MOD];
int hashing(unsigned int n){
return n % MOD;
}
bool find(long long n){
int h = hashing(n);
for(auto it : H[h])
if(it == n)
return 1;
return 0;
}
void insert(long long n){
int h = hashing(n);
H[h].push_back(n);
}
}ap;
int main(){
freopen("dtcsu.in","r",stdin);
freopen("dtcsu.out","w",stdout);
for(int i=1;i<=276997;++i){
ap.insert(GetInt());
}
long long q;
q=GetInt();
int sol=0;
while(q--){
if(ap.find(GetInt()))
++sol;
}
printf("%d\n",sol);
return 0;
}