Pagini recente » Cod sursa (job #3159048) | Cod sursa (job #1368503) | Cod sursa (job #340228) | Cod sursa (job #923833) | Cod sursa (job #3132698)
#include <iostream>
#include <vector>
#include <stdio.h>
#define NR 276997
#define HASHSIZE 65536
using namespace std;
vector<long long> h[HASHSIZE];
int cnt;
FILE *fin, *fout;
int gethash( long long no ) {
return no % HASHSIZE;
}
void readline() {
char ch = fgetc( fin ), str[20];
unsigned int i = 0;
while( ch != '\n' ) {
str[i++] = ch;
ch = fgetc( fin );
}
long long no = 0;
for( unsigned int j = 0; j < i; j++ )
no = no * 10 + str[j] - '0';
int key = gethash( no );
i = 0;
while( i < h[key].size() && h[key][i] != no )
i++;
if( i == h[key].size() )
h[key].push_back( no );
}
void hashfind( long long n ) {
int key = gethash( n );
unsigned int i = 0;
while( i < h[key].size() && h[key][i] != n )
i++;
if( i < h[key].size() )
cnt++;
}
int main() {
int i, q;
long long n;
fin = fopen( "dtcsu.in", "r" );
fout = fopen( "dtcsu.out", "w" );
for( i = 0; i < NR; i++ ) {
readline();//hashadd()
}
fscanf( fin, "%d", &q );
for( i = 0; i < q; i++ ) {
fscanf( fin, "%lld", &n );
hashfind( n );
}
fprintf( fout, "%d", cnt );
fclose( fin );
fclose( fout );
return 0;
}