Cod sursa(job #2300516)

Utilizator TooHappyMarchitan Teodor TooHappy Data 11 decembrie 2018 17:00:04
Problema Dtcsu Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <bits/stdc++.h>

using namespace std;

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

unordered_set< long long > uSet;

int main() {
    ios::sync_with_stdio(false); in.tie(0); out.tie(0);

    for (int i = 1; i <= 276997; ++i) {
        long long nr; in >> nr;
        if (nr % 2 != 0) {
            uSet.insert(nr);
        }
    }

    long long ans = 0;

    int Q; in >> Q;
    while (Q--) {
        long long n; in >> n;

        while (n % 2LL == 0) {
            n /= 2LL;
        }

        if (uSet.find(n) != uSet.end()) {
            ++ans;
        }
    }

    out << ans << "\n";

    in.close(); out.close();

    return 0;
}