Cod sursa(job #1561728)

Utilizator SilviuIIon Silviu SilviuI Data 4 ianuarie 2016 14:38:45
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <stdio.h>
#include <cmath>
#include <bitset>
#define lmax 276997
#define mod1 1666019
#define mod2 1756913
#define mod3 1756903
#define mod4 1564139
 
using namespace std;
typedef long long int ll;
 
int n,nr;
ll x;
bitset <mod1+10> uhash1;
bitset <mod2+10> uhash2;
bitset <mod3+10> uhash3;
bitset <mod4+10> uhash4;
 
int hash1(ll x) { return (x+21)%mod1; }
int hash2(ll x) { return (x+23)%mod2; }
int hash3(ll x) { return (x+19)%mod3; }
int hash4(ll x) { return (x+17)%mod4; }

int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);
    for (int i=1;i<=lmax;i++) {
        scanf("%lld",&x); 
        uhash1[hash1(x)]=1;  uhash2[hash2(x)]=1;  uhash3[hash3(x)]=1; uhash4[hash4(x)]=1;
    }
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%lld",&x);
        if (uhash1[hash1(x)]==1 && uhash2[hash2(x)]==1 && uhash3[hash3(x)]==1 && uhash4[hash4(x)]==1) nr++;
    }
    printf("%d",nr);
    return 0;
}