Pagini recente » Cod sursa (job #3166027) | Cod sursa (job #67199) | Cod sursa (job #2328587) | Cod sursa (job #60787) | Cod sursa (job #1973180)
#include <cstdio>
#include <vector>
#include <ctype.h>
const int HASH = 8192;
const int WHAT = 276997;
const int HASH2 = 1000000009;
const int BUFF = 4096;
std::vector<int> h[HASH];
FILE *fin;
int curr = BUFF - 1;
char buff[BUFF];
char getch() {
curr++;
if(curr == BUFF) {
fread(buff, 1, BUFF, fin);
curr = 0;
}
return buff[curr];
}
long long getnr() {
char ch;
ch = getch();
while(!isdigit(ch))
ch = getch();
long long nr = 0;
while(isdigit(ch)) {
nr = nr * 10 + ch - '0';
ch = getch();
}
return nr;
}
int main() {
int rez, q;
long long x;
rez = 0;
fin = fopen("dtcsu.in", "r");
for(int i = 0; i < WHAT; ++i) {
x = getnr();
x = x % HASH2;
h[x % HASH].push_back(x);
}
q = getnr();
for(int i = 0; i < q; ++i) {
x = getnr() % HASH2;
int box = x % HASH;
int j = 0;
while(j < h[box].size() && h[box][j] != x)
++j;
if(j < h[box].size())
++rez;
}
fclose(fin);
FILE *fout = fopen("dtcsu.out", "w");
fprintf(fout, "%d", rez);
fclose(fout);
return 0;
}