Cod sursa(job #3209308)

Utilizator AbRobertAbabei Robert-Petronel AbRobert Data 2 martie 2024 11:31:16
Problema Dtcsu Scor 20
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, Q, cnt = 0, gasit, r;
    long long x;
    ios_base::sync_with_stdio(0);
    fin.tie(0);
    fout.tie(0);
    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;
}