Cod sursa(job #1038704)

Utilizator romircea2010FMI Trifan Mircea Mihai romircea2010 Data 21 noiembrie 2013 21:44:01
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.31 kb
#include <iostream>
#include <cstdio>
#include <bitset>
#define NR2 10
#define NR 276997
#define MOD1 (1<<19)
#define MOD2 666013
#define MOD3 666019
#define MOD4 123457
#define MOD5 1000003

using namespace std;

bitset <MOD1> H1;
bitset <MOD2> H2;
bitset <MOD3> H3;
bitset <MOD4> H4;
bitset <MOD5> H5;

inline bool Good(const long long x)
{
    if (!H1[x&MOD1] || !H2[x%MOD2] || !H3[x%MOD3] || !H4[x%MOD4] || !H5[x%MOD5])
        return false;
    return true;
}

int main()
{
    char ch[500000];
    freopen("dtcsu.in", "r", stdin);
    for (int i = 1; i<=NR2; ++i)
    {
        gets(ch);
        long long x = 0LL;
        int ind;
        for (ind=0; ch[ind]; ++ind)
            x = x*10 + ch[ind] - '0';
        H1[x&MOD1] = true;
        H2[x%MOD2] = true;
        H3[x%MOD3] = true;
        H4[x%MOD4] = true;
        H5[x%MOD5] = true;
    }
    gets(ch);
    int Q = 0;
    int i;
    for (i=0; ch[i]; ++i)
        Q = Q*10 + ch[i] - '0';

    int answer = 0;
    while (Q--)
    {
        gets(ch);
        long long x = 0LL;
        int i;
        for (i=0; ch[i]; ++i)
            x = x*10 + ch[i] - '0';
        if (Good(x))
            ++answer;
    }

    FILE *g = fopen("dtcsu.out", "w");
    fprintf(g, "%d\n", answer);
    fclose(g);


    return 0;
}