Cod sursa(job #1034420)

Utilizator PetcuIoanPetcu Ioan Vlad PetcuIoan Data 17 noiembrie 2013 20:20:25
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <cstdio>
#include <cstring>

#include <algorithm>
#include <vector>

using namespace std;

const int kmod = 65535;

vector<long long> h[kmod + 1];

int key, j;

void add(long long &t){
  key = t & kmod;
  for(j = 0; j < h[key].size(); ++j)
    if(t == h[key][j])
      return;
  h[key].push_back(t);
}

inline bool isthere(long long &t){
  key = t & kmod;
  for(j = 0; j < h[key].size(); ++j)
    if(t == h[key][j])
      return true;
  return false;
}

char pars[22];

int p;
inline void nex(long long &t){
  p = t = 0;
  gets(pars);
  while(pars[p] <= '9' && pars[p] >= '0'){
    t = t * 10 + pars[p] - '0';
    ++p;
  }
}

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

  long long t;
  for(int i = 1; i <= 276997; ++i){
    nex(t);
    t /= (t & -t);
    add(t);
  }

  long long q;
  int ans = 0;

  nex(q);
  for(int i = 1; i <= q; ++i){
    nex(t);
    t /= (t & -t);
    if(isthere(t))
      ++ans;
  }

  printf("%d", ans);

  return 0;
}