Cod sursa(job #1498556)

Utilizator justsomedudePalade Thomas-Emanuel justsomedude Data 8 octombrie 2015 19:03:16
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.88 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;
	freopen("dtcsu.in", "r", stdin);
    freopen("dtcsu.out", "w", stdout);
    for (i=1; i <= 276997; i++)
    {
        gets(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);
    }
    scanf("%d", &M);
    for (i=1; i <= M; i++)
    {
        gets(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;
    }
    printf("%d\n", cnt);
    return 0;
}