Cod sursa(job #3209317)

Utilizator ciucelizamariaeliza ciuc ciucelizamaria Data 2 martie 2024 11:33:52
Problema Dtcsu Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.69 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;
        if (x > 0)
        {
            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;
}