Cod sursa(job #1774566)

Utilizator tamionvTamio Vesa Nakajima tamionv Data 9 octombrie 2016 02:23:14
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <bits/stdc++.h>
using namespace std;

constexpr int n = 276997;

FILE *f = fopen("dtcsu.in", "r"),
	 *g = fopen("dtcsu.out", "w");
char buf[10000], *p, *ep;

void init_p(){
	fread(p=buf, 1, sizeof(buf), f);
	ep = p + sizeof(buf); }

void adv(){
	if(++p == ep){
		fread(p=buf, 1, sizeof(buf), f); } }

using ll = long long;

ll get_ll(){
	ll r = 0;
	for( ; *p == '\n' || *p == ' '; adv());
	for( ; *p != '\n' && *p != ' '; adv()) r = (10 * r + *p - '0');
	return r; }

int main(){
	init_p();
	vector<ll> v;
	v.reserve(n/2);
	for(int i = 0; i < n; ++i){
		const ll x = get_ll();
		if(x&1) v.push_back(x); }

	sort(begin(v), end(v));

	ll q = get_ll(), r = 0;
	for(ll x; q--; ){
		x = get_ll();
		if(x != 0 && binary_search(begin(v), end(v), x / (x&-x))) ++r; }
	fprintf(g, "%lld\n", r);

	return 0; }