Cod sursa(job #1498557)

Utilizator justsomedudePalade Thomas-Emanuel justsomedude Data 8 octombrie 2015 19:08:36
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.89 kb
#include <bits/stdc++.h>

using namespace std;

#define P 19997
vector<long long> L[P+1];

int main()
{
	char s[30];
	long long x;
    int i, M, cnt = 0, ok, r;
    unsigned int j;
	ifstream fin ("dtcsu.in");
    ofstream fout ("dtcsu.out");
    for (i=1; i <= 276997; i++)
    {
        fin >> s;
        x = 0;
        for (i = 0; s[i] != 0; i++)
            x = x * 10 + (s[i] - '0');
        if (x % 2 == 1)
            L[x%P].push_back(x);
    }
    fin >> M;
    for (i=1; i <= M; i++)
    {
        fin>>s;
        x = 0;
        for (i = 0; s[i] != 0; i++)
            x = x * 10 + (s[i] - '0');
        while (x % 2 == 0)
            x /= 2;
        ok =0;
        r = x % P;
        for (j=0; j<L[r].size() && ok==0; j++)
            if (L[r][j] == x) ok = 1;
        cnt += ok;
    }
    fout << cnt;
    fin.close();
    fout.close();
    return 0;
}