Pagini recente » Cod sursa (job #2765839) | Cod sursa (job #2616680) | Cod sursa (job #3137444) | Cod sursa (job #2940419) | Cod sursa (job #1033844)
#include<stdio.h>
#include<algorithm>
using namespace std;
FILE*g=fopen("dtcsu.out","w");
const int len = 57000;
long long A[len+5];
int ch,in,sol;
const int n = 276997;
char buff[23];
int main () {
int l = 1,r = len;
for ( ; l <= n ; ){
FILE*f=fopen("dtcsu.in","r");
in = 0;
long long x = 0;
for ( int i = 1 ; i <= n ; ++i ){
fgets(buff,20,f);
if ( i >= l && i <= r ){
x = 0;
ch = 0;
while ( buff[ch] >= '0' && buff[ch] <= '9' ){
x = x*10 + buff[ch]-'0';
++ch;
}
A[++in] = x;
}
}
int q = 0;
fgets(buff,20,f); ch = 0;
while ( buff[ch] >= '0' && buff[ch] <= '9' ){
q = q*10 + buff[ch]-'0';
++ch;
}
sort(A+1,A+in+1);
int left,middle,right;
for ( int i = 1 ; i <= q ; ++i ){
fgets(buff,20,f);
long long x = 0;
ch = 0;
while ( buff[ch] >= '0' && buff[ch] <= '9' ){
x = x*10 + buff[ch]-'0';
++ch;
}
if ( x < A[1] || x > A[in] ) continue ;
left = 1,right = in;
while ( left <= right ){
middle = (left+right)>>1;
if ( A[middle] == x ){
++sol; break ;
}
if ( A[middle] < x ){
left = middle+1;
}
else{
right = middle-1;
}
}
}
l += len,r += len;
fclose(f);
}
fprintf(g,"%d\n",sol);
fclose(g);
return 0;
}