Cod sursa(job #3209310)

Utilizator dnprxDan Pracsiu dnprx Data 2 martie 2024 11:31:31
Problema Dtcsu Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <bits/stdc++.h>
#define P 8887
using namespace std;

ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");
vector<long long> M[P];

int main()
{
    int i, n, r, Q, cnt = 0, gasit;
    long long x;
    for (i = 1; i <= 276997; i++)
    {
        fin >> x;
        x /= (x & (-x)); /// while (x%2==0) x/=2;
        M[x % P].push_back(x);
    }
    fin >> Q;
    while (Q--)
    {
        fin >> x;
        x /= (x & (-x));
        gasit = 0;
        r = x % P;
        for (long long e : M[r])
            if (e == x) gasit = 1;
        cnt += gasit;
    }
    fout << cnt << "\n";
    return 0;
}