Pagini recente » Cod sursa (job #2001830) | Cod sursa (job #2149159) | Cod sursa (job #2352034) | Cod sursa (job #1311312) | Cod sursa (job #2828897)
#include <fstream>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <algorithm>
using namespace std;
FILE *fin = fopen("dtcsu.in", "r");
ofstream fout("dtcsu.out");
const int bsize = 1<<16; //bsize = dimensiunea blocurilor in care sparg fisierul de intrare
char buff[bsize];
int poz = bsize;
inline char next() //citeste urmatorul caracter
{
if (poz == bsize) //daca am terminat de procesat blocul actual, mai citesc inca un bloc
{
fread(buff, 1, bsize, fin);
poz = 0;
}
return buff[poz++];
}
long long nr() //citeste un numar pozitiv
{
long long x = 0;
char c;
do
{
c = next();
} while (isdigit(c) == 0); //sar peste spatii
while (isdigit(c)) //citesc cifra cu cifra
{
x = x * 10 + c-48;
c = next();
}
return x;
}
long long v[300000];
bool cb (long long x)
{
int st = 1, dr = 276997, mij;
while (st <= dr)
{
mij = (st+dr)>>1;
if (v[mij] == x)
return 1;
if (v[mij] < x)
st = mij + 1;
else
dr = mij - 1;
}
return 0;
}
int main()
{
int q, i, rasp;
long long n;
for (i = 1; i<=276997; i++)
v[i] = nr();
sort(v+1, v+276997+1);
q = nr();
rasp = 0;
for (i = 1; i<=q; i++)
{
n = nr();
if (cb (n) == 1)
rasp++;
}
fout << rasp;
return 0;
}