Cod sursa(job #1497911)

Utilizator vladrochianVlad Rochian vladrochian Data 7 octombrie 2015 19:32:26
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.99 kb
#include <fstream>
#include <unordered_set>
using namespace std;

class Parser {
 public:
  Parser(const char *path) {
    in.open(path);
    in.read(buffer, kSize);
    cursor = 0;
  }
  template<class Int> Parser& operator>>(Int &x) {
    x = 0;
    while (!isdigit(buffer[cursor]))
      advance();
    while (isdigit(buffer[cursor])) {
      x = x * 10 + buffer[cursor] - '0';
      advance();
    }
    return *this;
  }
 private:
  void advance() {
    if (++cursor == kSize) {
      in.read(buffer, kSize);
      cursor = 0;
    }
  }
  static const int kSize = 100000;
  ifstream in;
  char buffer[kSize];
  int cursor;
} fin("dtcsu.in");
ofstream fout("dtcsu.out");

unordered_set<int64_t> s;
int Q, ans;

int main() {
  for (int i = 0; i < 276997; ++i) {
    int64_t x;
    fin >> x;
    if (x & 1) s.insert(x);
  }
  fin >> Q;
  while (Q--) {
    int64_t x;
    fin >> x;
    ans += (x && s.count(x / (x & -x)));
  }
  fout << ans << "\n";
  return 0;
}