Cod sursa(job #2300373)

Utilizator sandupetrascoPetrasco Sandu sandupetrasco Data 11 decembrie 2018 11:16:09
Problema Dtcsu Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define MOD 666013
#define z(x) (x & (-x))

using namespace std;
typedef long long ll;
typedef pair< ll , ll > PII;
 
int n, q, rs;
ll x;
unordered_set < ll > S;
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    ifstream cin("dtcsu.in");
    ofstream cout("dtcsu.out");

	for (int i = 1; i <= 276997; i++) {
		cin >> x;
		if (x & 1LL) S.insert(x);
	}

	cin >> q;
	while (q--) {
		cin >> x;
		if (!x) continue;
		rs += S.find(x / z(x)) != S.end();
	}

	cout << rs;
	return 0;
}