Cod sursa(job #2315373)

Utilizator Mihai145Oprea Mihai Adrian Mihai145 Data 9 ianuarie 2019 21:23:11
Problema Dtcsu Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <fstream>
#include <unordered_set>

using namespace std;

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

int Q, sol;
unordered_set <long long> S;

int main()
{
    long long x;
    for(int i = 1; i <= 276997; i++)
    {
        fin >> x;

        if(x & 1)
            S.insert(x);
    }

    fin >> Q;
    for(int i = 1; i <= Q; i++)
    {
        fin >> x;

        if(x < 0)
            continue ;

        long long lastBit = x & (-x);

        if(S.find(x / lastBit) != S.end())
            sol++;
    }

    fout << sol;
    return 0;
}