Cod sursa(job #2206974)

Utilizator Alex_BubBuburuzan Alexandru Alex_Bub Data 24 mai 2018 17:28:53
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <bits/stdc++.h>

using namespace std;

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

const int NMAX = 276997;

unordered_set <long long> v;

long long read() {
    string s;

    getline(fin, s);

    long long x = 0;

    for(string :: iterator it = s.begin(); it < s.end(); it++)
            x = x * 10 + (*it - '0');

    return x;
}

int main()
{
    int nr = 0;

    long long x, k;

    for(int i = 0; i < NMAX; i++) {
        x = read();

        v.insert(x / (x & (-x)));
    }

    k = read();

    while(k--) {
        x = read();

        if(x && v.find(x / (x & (-x))) != v.end()) nr++;
    }

    fout << nr;

    fin.close();
    fout.close();

    return 0;
}