Cod sursa(job #556862)

Utilizator KosmynC64Munteanu Cosmin KosmynC64 Data 16 martie 2011 12:42:14
Problema Hashuri Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
#include<fstream>
#include<vector>
#include<cmath>
#define HASH_SIZE 183746
using namespace std;
int hash(int x){
return (int)floor((float)x*0.6162)%HASH_SIZE;}
int main(){
    vector<int> h(HASH_SIZE);
    int n,d1,d2;
    ifstream f("hashuri.in");
    ofstream g("hashuri.out");
    f>>n;
    for(;n;--n){
        f>>d1>>d2;
        if(d1==1){h[hash(d2)]=d2;}
        if(d1==2){h[hash(d2)]=0;}
        if(d1==3&&h[hash(d2)]==0)g<<"0\n";
        if(d1==3&&h[hash(d2)]!=0)g<<"1\n";}
return 0;}