Cod sursa(job #1389463)

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

using namespace std;

class Buffer{
    public:
        long maxBuf,pos;
        vector<char> Buff;

        Buffer(char fileName[],long buffSize){
            freopen(fileName,"r",stdin);
            maxBuf = buffSize; Buff.resize(maxBuf);
            reFill();
        }

        Buffer& operator>>(long long &dest){
            while(!isDigit(Buff[pos])){
                pos++;
                if(pos == maxBuf) reFill();
            }
            dest = 0;
            while(isDigit(Buff[pos])){
                dest = dest*10 + Buff[pos++] - '0';
                if(pos == maxBuf) reFill();
            }
            return *this;
        }

    private:
        bool isDigit(char c){
            return c >= '0' & c <= '9';
        }
        void reFill(){
            fread(&Buff[0],1,maxBuf,stdin); pos = 0;
        }
};


#define cntRead 276997
#define mod1 66013
#define mod2 36117
#define mod3 73571
#define cin fin

long i,cnt;
long long x,n;
bitset<mod1> B1;
bitset<mod2> B2;
bitset<mod3> B3;

inline long h1(long long x){
    return x%mod1;
}
inline long h2(long long x){
    return x%mod2;
}
inline long h3(long long x){
    return x%mod3;
}

int main()
{
    Buffer cin("dtcsu.in",1024*256);
    freopen("dtcsu.out","w",stdout);

    x=3;
    for(i=1;i<=cntRead;i++){
        cin >> x;
        //if(x&1)
            B1[h1(x)]=1;B2[h2(x)]=1;B3[h3(x)]=1;
    }

    cin >> n;
    for(i=1;i<=n;i++){
        cin >> x;
        //x /= (x^(x-1))&x;
        if(B1[h1(x)]==1 && B2[h2(x)]==1 && B3[h3(x)]==1) cnt++;
    }
    printf("%ld",cnt);

    return 0;
}