Pagini recente » Cod sursa (job #78857) | Arhiva de probleme | Cod sursa (job #703840) | Profil SpiriFlaviu | Cod sursa (job #1033780)
#include <stdio.h>
#include <assert.h>
#include <algorithm>
using namespace std;
int n;
long long v[50002];
long long p2[10];
int cautare (long long x)
{
int st = 1, dr = v[0], m, sol=1;
while (st <= dr)
{
m = (st + dr) >> 1;
if (v[m] >= x)
{
sol = m;
dr = m - 1;
}
else
st = m + 1;
}
return v[sol] == x;
}
int main ()
{
freopen ("dtcsu.in", "r", stdin);
freopen ("dtcsu.out", "w", stdout);
long long x = 0;
int i, j, sol = 0;
char s[22];
int cate = 276997;
for (i = 1; i <= cate; i ++)
{
gets (s + 1);
x = 0;
for (j = 1; '0' <= s[j] && s[j] <= '9'; j ++)
x = x * 10 + s[j] - '0';
if (x % 2 == 0)
continue;
else
v[++v[0]] = x;
}
assert (v[0] <= 50000);
p2[0] = 1 << 30;
p2[1] = 1 << 16;
p2[2] = 1 << 8;
p2[3] = 1 << 4;
p2[4] = 1 << 2;
p2[5] = 1 << 1;
sort (v + 1, v + v[0] + 1);
scanf ("%d\n", &n);
while (n --)
{
gets (s + 1);
x = 0;
for (j = 1; '0' <= s[j] && s[j] <= '9'; j ++)
x = x * 10 + s[j] - '0';
if ((x & 1) == 0)
{
if ((x & p2[0] - 1) == 0)
x >>= 30;
if ((x & p2[1] - 1) == 0)
x >>= 16;
if ((x & p2[2] - 1) == 0)
x >>= 8;
if ((x & p2[3] - 1) == 0)
x >>= 4;
if ((x & p2[4] - 1) == 0)
x >>= 2;
if ((x & p2[5] - 1) == 0)
x >>= 1;
}
if (cautare(x))
sol ++;
}
printf ("%d\n", sol);
return 0;
}