Pagini recente » Cod sursa (job #134564) | Diferente pentru runda/pre_oni_gim2015 intre reviziile 15 si 27 | Istoria paginii runda/sevennationarmy | Rating Kai Butler (acinstallation955) | Cod sursa (job #2795891)
#include <stdio.h>
#include <vector>
#include <ctype.h>
#define CARDINAL 276997
#define HASH_SIZE 10007
using namespace std;
FILE *fin, *fout;
vector<long long> hTable[HASH_SIZE];
void add(long long x) {
hTable[x % HASH_SIZE].push_back(x);
}
bool search( long long x ) {
int h, i;
h = x % HASH_SIZE;
i = 0;
while(i < hTable[h].size() && hTable[h][i] != x)
i++;
return i < hTable[h].size();
}
long long readInt() {
long long n = 0;
char ch;
while(!isdigit(ch = fgetc(fin)));
do {
n = n * 10 + ch - '0';
}while(isdigit(ch = fgetc(fin)));
return n;
}
int main() {
long long n, i, ans;
long long x;
fin = fopen("dtcsu.in", "r");
for(i = 0; i < CARDINAL; i++) {
x = readInt();
add(x);
}
n = readInt();
ans = 0;
for(i = 0; i < n; i++) {
x = readInt();
ans += search(x);
}
fclose(fin);
fout = fopen("dtcsu.out", "w");
fprintf(fout, "%lld", ans);
fclose(fout);
return 0;
}