Cod sursa(job #1867967)

Utilizator moise_alexandruMoise Alexandru moise_alexandru Data 4 februarie 2017 14:31:24
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in("dtcsu.in");
ofstream out("dtcsu.out");
const int numnr = 276997;
const int mod = 666013;
vector <long long> hsh[mod];

void _insert_(long long x)
{
    int p = x % mod;
    hsh[p].push_back(x);
}

bool _find_(long long x)
{
    int p = x % mod;
    for(auto it : hsh[p])
        if(it == x)
            return 1;
    return 0;
}

int main()
{
    for(int i = 1; i <= numnr; i++)
    {
        long long x;
        in >> x;
        _insert_(x);
    }
    int q;
    in >> q;
    int nr = 0;
    for(int i = 1; i <= q; i++)
    {
        long long x;
        in >> x;
        if(_find_(x) == 1)
            nr++;
    }
    out << nr << "\n";
    return 0;
}