Cod sursa(job #1068009)

Utilizator antonioteoZait Teodor Antonio antonioteo Data 27 decembrie 2013 19:55:17
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <fstream>
using namespace std;

ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");

#define ll long long
#define mod 100001

ll a;
int ans;
int i, j, Q;
int n = 276997;

struct nod {
	ll x;
	nod *next;
};
nod *H[mod + 3];

void add(ll v) {
	int t = v % mod;
	nod *p = new nod;
	p->x = v;
	p->next = H[t];
	H[t] = p;
}

inline int search_hash(ll v) {
	int t = v % mod;
	for (nod *it = H[t]; it; it = it->next) 
		if (it->x == v) return 1;
	return 0;
}

int main() {
	for (i = 1; i <= n; ++i) {
		fin >> a;
		if (a & 1LL) 
			add(a);
	}
	fin >> Q;
	while (Q--) {
		fin >> a;
		if (a && search_hash(a /(a &(-a))))
			++ans;
	}
	fout << ans << '\n';
	return 0;
}