Cod sursa(job #2206449)

Utilizator Stefan_RaduStefan Radu Stefan_Radu Data 22 mai 2018 18:37:06
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <iostream>
#include <unordered_set>

using namespace std;

int main () {

  freopen ("dtcsu.in", "r", stdin);
  freopen ("dtcsu.out", "w", stdout);

  unordered_set < long long > s;

  int k = 276997;

  long long x;
  while (k --) {
      
    scanf ("%lld", &x);

    while (x and not x & 1) {
      x >>= 1;
    }

    if (x) {
      s.insert (x);
    }
  }

  int q;
  scanf ("%d", &q);

  int cnt = 0;
  while (q --) {

    scanf ("%lld", &x);

    while (x and not x & 1) {
      x >>= 1;
    }

    if (x and s.find (x) != s.end ()) {
      ++ cnt;
    }
  }

  printf ("%d\n", cnt);
}