Cod sursa(job #1030723)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 15 noiembrie 2013 16:51:10
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.79 kb
#include<fstream>
#include<algorithm>
using namespace std;
typedef struct celula{
           int val;
           celula *next;
           }*lista;
const int mod=666013;
lista h[666013],v;
int i,q,x,sol;

void baga(int val) {
       int r=val%mod;
       v=new celula; v->val=val; v->next=h[r]; h[r]=v;
}

bool este(int val) {
     int r=val%mod;
       bool ok=0;
       for (lista p=h[r]; p; p=p->next) 
        if (p->val==val) { ok=0; break; }
       return(ok);
}

int main(void) {
     ifstream fin("dtcsu.in");
     ofstream fout("dtcsu.out");
     for (i=1; i<=276997; ++i) {
           fin>>x;
           baga(x);
           }
     fin>>q;
     for (i=1; i<=q; ++i) {
           fin>>x;
           if ( este(x) ) ++sol;
           }
   fout<<sol;
 return(0);
}