Cod sursa(job #1268062)

Utilizator ThomasFMI Suditu Thomas Thomas Data 20 noiembrie 2014 16:31:39
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>
#include <unordered_map>
using namespace std;

#define NMax 276997

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

unordered_map<int, long long> M;

long long q,nr,x;

int main()
{
    int i;
    for(i=1;i<=NMax;++i)
    {
        f>>x;
        if(x&1) M[x] = i;
    }

    f>>q;
    while(q--)
    {
        f>>x;
        if (x & (-x)) x /= x & (-x);
        if(x && M.find(x)!=M.end()) ++nr;
    }

    g<<nr<<"\n";

    f.close();
    g.close();
    return 0;
}