Cod sursa(job #1034001)

Utilizator mihai995mihai995 mihai995 Data 17 noiembrie 2013 16:50:01
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.07 kb
#include <cstdio>
#include <bitset>
using namespace std;

template<const int Size, const int nrHash>
class BloomFilter{
    bitset<Size> B;

public:
    void update(unsigned long long x){
        int times = nrHash;
        while (times--){
            B[x % Size] = true;
            x >>= 1;
        }
    }

    bool query(unsigned long long x){
        int times = nrHash;
        while (times--){
            if (!B[x % Size])
                return false;
            x >>= 1;
        }
        return true;
    }
};

BloomFilter<5607389, 60> B;
const int buffSize = 1 << 17;
char buff[buffSize];

int main(){
    int times = 276997, ans = 0;
    long long x;

    FILE* in = fopen("dtcsu.in", "r");
    FILE* out = fopen("dtcsu.out", "w");
    setvbuf(in, buff, _IOFBF, buffSize);

    while (times--){
        fscanf(in, "%lld", &x);
        B.update(x);
    }
/*
    fscanf(in, "%d", times);
    while (times--){
        fscanf(in, "%lld", &x);
        ans += B.query(x);
    }
*/
    fprintf(out, "%d\n", ans);

    return 0;
}