Cod sursa(job #2790514)

Utilizator tomaionutIDorando tomaionut Data 29 octombrie 2021 10:29:41
Problema Dtcsu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <bits/stdc++.h>
#define P 10007
using namespace std;

ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");
vector<long long> h[P];
long long sol = 0;
void Add(long long x)
{
    int r = x % P;
    h[r].push_back(x);
}
bool Check(long long x)
{
    int r = x % P;
    for (auto w : h[r])
        if (w == x) return 1;
    return 0;
}
int main()
{
    int i;
    long long x,q;
    for (i = 1; i <= 276997; i++)
    {
        fin >> x;
        Add(x);
    }
    fin >> q;
    while (q--)
    {
        fin >> x;
        sol += Check(x);
    }
    return 0;
}