Cod sursa(job #1782698)

Utilizator mantisVraciu Stefan mantis Data 18 octombrie 2016 15:16:37
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda hash_excelenta Marime 0.68 kb
#include<fstream>
#include<vector>
#define MOD 9013
using namespace std;

ifstream f("dtcsu.in");
ofstream g("dtcsu.out");

int n,nr;
vector<long long> H[MOD+2];

int main()
{
    long long x;
    for(int i=1;i<=276997;i++)
    {
        f>>x;
        if(x%2==1) H[x%MOD].push_back(x);
    }
    f>>n;
    for(int i=1;i<=n;i++)
    {
        f>>x;
        if(x)
        {
            while(x%2==0)
                x/=2;
            vector<long long>::iterator it=H[x%MOD].begin(), sf=H[x%MOD].end();
            bool w=1;
            for(;it!=sf && w;it++)
                if((*it)==x) {nr++; w=0;}
        }
    }
    g<<nr;
    g.close();
    return 0;
}