Cod sursa(job #1991022)

Utilizator Moise_AndreiMoise Andrei Moise_Andrei Data 14 iunie 2017 17:52:43
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in("dtcsu.in");
ofstream out("dtcsu.out");
vector <long long> v[8195];
int main()
{
    int M, cnt = 0, ok, r;
    for(int i = 1; i <= 276997; i++)
    {
        long long x;
        in >> x;
        if(x % 2 == 1)
            v[x % 8191].push_back(x);
    }
    in >> M;
    for(int i = 1; i <= M; i++)
    {
        long long x;
        in >> x;
        if (x > 0)
            x = x / (x & (-x));
        ok = 0;
        r = x % 8191;
        for(int j = 0; j < v[r].size() && ok == 0; j++)
            if(v[r][j] == x)
                ok = 1;
        cnt += ok;
    }
    out << cnt << "\n";
    return 0;
}