Cod sursa(job #1389421)

Utilizator atatomirTatomir Alex atatomir Data 16 martie 2015 11:28:57
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 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> B;

long h1(long _x){
    long long x = _x;
    return (x*(x^(x-1))*32947)%mod;
}
long h2(long _x){
    long long x = _x;
    return (x*(x&(x+1)+13)*333447)%mod;
}
long h3(long _x){
    long long x = _x;
    return (((x*17)+32)^(x/32))%mod;
}

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

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

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

    return 0;
}