Cod sursa(job #3256317)

Utilizator Carnu_EmilianCarnu Emilian Carnu_Emilian Data 14 noiembrie 2024 09:20:19
Problema Dtcsu Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fcin("dtcsu.in");
ofstream fcout("dtcsu.out");

const int P = 8887;
std::vector<long long> h[P];
int n, m, rasp;

int cautare(long long x)
{
    int r = x % P;
    for (long long e : h[r])
        if (e == x)
            return 1;
    return 0;
}

int main()
{
    long long x;
    for (int i = 1; i <= 276997; i++)
    {
        fcin >> x;
        x = x / (x & -x);
        h[x % P].push_back(x);
    }
    int q;
    fcin >> q;
    while (q--)
    {
        fcin >> x;
        if (x > 0)
        {
            x = x / (x & -x);
            rasp += cautare(x);
        }
    }
    fcout << rasp;
    return 0;
}