Cod sursa(job #1601302)

Utilizator T.C.11Tolan Cristian T.C.11 Data 15 februarie 2016 20:51:51
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <fstream>
#include <vector>
#define nr 276997
#define MOD 9013

using namespace std;

ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");

vector<long long int> h[MOD+10];

int check(long long int x)
{
    long long int xx = x%MOD;
    for (vector<long long int>::iterator it = h[xx].begin(); it != h[xx].end(); it ++)
    {
        if (*it == x)
            return 1;
    }
    return 0;
}

int i,j,q,sol;
long long int x;

int main()
{
    for (i=1;i<=nr;i++)
    {
        fin>>x;
        if (x&1)
            h[x%MOD].push_back(x);
    }
    fin>>q;
    for (i=1;i<=q;i++)
    {
        fin>>x;
        if (x!=0)
        {
            while (!(x&1))
                x>>=1;
            sol+=check(x);
        }
    }
    fout<<sol;
    return 0;
}