Cod sursa(job #2791587)

Utilizator Teodor94Teodor Plop Teodor94 Data 30 octombrie 2021 19:59:55
Problema Dtcsu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.02 kb
#include <stdio.h>
#include <ctype.h>
#include <unordered_set>
using namespace std;

#define int64 long long
#define NO_NUMBERS 276997

FILE *fin, *fout;
int64 readInt64() {
  char ch;
  int64 res;

  res = 0;
  while (!isdigit(ch = fgetc(fin)));
  do
    res = res * 10 + ch - '0';
  while (isdigit(ch = fgetc(fin)));

  return res;
}

int64 removePow2(int64 x) {
  int step;

  step = 32;
  while (step) {
    if ((x & ((1 << step) - 1)) == 0)
      x >>= step;
    step >>= 1;
  }

  return x;
}

unordered_set<int64> myHash;

int main() {
  fin = fopen("grader_test1.in", "r");
  fout = fopen("dtcsu.out", "w");

  int i, q, counter;
  int64 x;

  for (i = 0; i < NO_NUMBERS; ++i) {
    x = readInt64();

    if (x & 1)
      myHash.insert(x);
  }

  counter = 0;
  q = readInt64();
  while (q--) {
    x = readInt64();
    x = removePow2(x);

    counter += myHash.find(x) != myHash.end();
  }

  fprintf(fout, "%d\n", counter);

  fclose(fin);
  fclose(fout);
  return 0;
}