Cod sursa(job #2003380)

Utilizator TincaMateiTinca Matei TincaMatei Data 22 iulie 2017 20:02:53
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <cstdio>

typedef long long i64;
const int NR_BAZE = 4;
const int MAX_BAZA = 100000;
const int MADJICK = 276997;
const int MADJICKHASH = 499979;

bool bloom[MADJICKHASH];

int main() {
  int s = 0, q, no = 0;
  i64 x;
  FILE *fin = fopen("dtcsu.in", "r");
  for(int i = 0; i < MADJICK; ++i) {
    fscanf(fin, "%lld", &x);
    if(x & 1)
      bloom[x % MADJICKHASH] = true;
  }
  fscanf(fin, "%d", &q);
  for(int i = 0; i < q; ++i) {
    fscanf(fin, "%lld", &x);
    while(!(x & 1))
      x >>= 1;
    s += bloom[x % MADJICKHASH];
  }
  fclose(fin);
  FILE *fout = fopen("dtcsu.out", "w");
  fprintf(fout, "%d", s);
  fclose(fout);
  return 0;
}