Pagini recente » Cod sursa (job #580725) | Cod sursa (job #2678099) | Cod sursa (job #777037) | Cod sursa (job #605007) | Cod sursa (job #1935938)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");
typedef long long int ll;
const int NMax = 276997;
const int BMax = 5e4 + 5;
ll v[NMax];
int pos = BMax - 1;
char Buffer[BMax];
inline void Read(ll &x) {
while(!isdigit(Buffer[pos])) {
if(++pos == BMax) {
pos = 0;
fin.read(Buffer, sizeof(Buffer));
}
}
x = 0;
while(isdigit(Buffer[pos])) {
x = x * 10 + (Buffer[pos] - '0');
if(++pos == BMax) {
pos = 0;
fin.read(Buffer, sizeof(Buffer));
}
}
}
inline bool Binary(const ll &value) {
int lo = 0;
int hi = NMax - 1;
while(lo <= hi) {
int mid = (lo + hi) >> 1;
if(v[mid] == value) return true;
if(v[mid] < value) {
lo = mid + 1;
} else {
hi = mid - 1;
}
}
return false;
}
int main(){
ios::sync_with_stdio(false);
for(int i = 1; i <= NMax; i++) Read(v[i]);
ll n;
Read(n);
int ans = 0;
while(n--) {
ll x;
Read(x);
if(Binary(x) == true) ans++;
}
fout << ans;
return 0;
}