Cod sursa(job #1389433)

Utilizator atatomirTatomir Alex atatomir Data 16 martie 2015 11:38:58
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <iostream>
#include <cstdio>
#include <bitset>

using namespace std;

#define cntRead 276997
#define mod 4000000

long n,i,cnt;
long long x;
bitset<mod+11> B;

long h1(long long x){
        x%= 321421312;
    x=(x*173)/9+1;
    return x%mod;
}
long h2(long long x){
        x%= 321321341;
    x=(x*312344)/1231+33;
    return x%mod;
}
long h3(long long x){
        x%=123412564;
    x=(x*99313)^(x*231412);
    return x%mod;
}

int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);

    for(i=1;i<=cntRead;i++){
        scanf("%lld",&x);
        if(x&1)
            B[h1(x)]=1;B[h2(x)]=1;B[h3(x)]=1;
    }

    scanf("%ld",&n);
    for(i=1;i<=n;i++){
        scanf("%lld",&x);
        x /= (x^(x-1))&x;
        if(B[h1(x)]==1 && B[h2(x)]==1 && B[h3(x)]==1) cnt++;
    }
    printf("%ld",cnt);

    return 0;
}