Cod sursa(job #1198514)

Utilizator radustn92Radu Stancu radustn92 Data 15 iunie 2014 22:01:46
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.24 kb
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#define ll long long
using namespace std;

const int no = 276997;
const int LMAX = (1 << 16);
const int NMAX = (1 << 17);
char buff[LMAX];
int pos = 0, q, N = 5, res;
bitset <NMAX> mark;
int A[] = {2, 3, 5, 7, 11};

inline ll parseLL()
{
	ll x = 0;
	while (!isdigit(buff[pos]))
		if (++pos == LMAX)
			fread(buff, 1, LMAX, stdin), pos = 0;
	
	while (isdigit(buff[pos]))
	{
		x = x * 10 + buff[pos] - '0';
		if (++pos == LMAX)
			fread(buff, 1, LMAX, stdin), pos = 0;
	}
	
	return x;
}

inline ll get(ll x, int i, int j)
{
	x >>= (1LL << (i - 1));
	return x & ((1LL << (j - i + 1)) - 1);
}

void insert_filter(ll x)
{
	mark[get(x, 2, 18)] = 1;
	mark[get(x, 5, 21)] = 1;
}

inline int fails_filter(ll x)
{
	if (!mark[get(x, 2, 18)]) return 1;
	if (!mark[get(x, 5, 21)]) return 1;
	
	return 0;
}

unordered_set <ll> H;

int main()
{
	freopen("dtcsu.in", "r", stdin);
	freopen("dtcsu.out", "w", stdout);
	
	ll x;
	for (register int i = 1; i <= no; i++)
	{
		x = parseLL();
		if (x & 1)
			H.insert(x);
	}
	
	q = parseLL();
	for (register int i = 1; i <= q; i++)
	{
		x = parseLL();
		if (!(x & 1))
			x /= (x & -x);
		
		if (H.find(x) != H.end()) res++;
	}
	
	printf("%d\n", res);
	return 0;
}