Cod sursa(job #2689398)

Utilizator fminostress9FMI No Stress 9 fminostress9 Data 20 decembrie 2020 16:50:03
Problema Dtcsu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.61 kb
#include <bits/stdc++.h>

using namespace std;
#define go(x, d) while (x % d == 0) x /= d;

struct InParser {
  FILE *fin;
  char *buff;
  int sp;

  char read_ch() {
    ++sp;
    if (sp == 4096) {
      sp = 0;
      fread(buff, 1, 4096, fin);
    }
    return buff[sp];
  }

  InParser(const char* nume) {
    fin = fopen(nume, "r");
    buff = new char[4096]();
    sp = 4095;
  }

  InParser& operator >> (long long &n) {
    char c;
    n = 0;
    while (!isdigit(c = read_ch()));
    while (isdigit(c = read_ch())) {
      n = 10 * n + c - '0';
    }
    return *this;
  }
  void skip(int cnt) {
    for (int i = 0; i < cnt; ++i) {
      while (read_ch() == '\n');
      while (read_ch() != '\n');
    }
  }
};

int main() {
  InParser cin("dtcsu.in");
  ofstream cout("dtcsu.out");
  cin.skip(276997);
  long long q; cin >> q;
  int tot = 0;
  
  while (q > 4) {
    long long x, y, z, t; cin >> x >> y >> z >> t;
    go(x, 128); go(y, 128); go(z, 128); go(t, 128);
    go(x, 2); go(y, 2); go(z, 2); go(t, 2);
    go(x, 243); go(y, 243); go(z, 243); go(t, 243);
    go(x, 3); go(y, 3); go(z, 3); go(t, 3);
    go(x, 625); go(y, 625); go(z, 625); go(t, 625);
    go(x, 5); go(y, 5); go(z, 5); go(t, 5);
    go(x, 2401); go(y, 2401); go(z, 2401); go(t, 2401);
    go(x, 7); go(y, 7); go(z, 7); go(t, 7);
    go(x, 1331); go(y, 1331); go(z, 1331); go(t, 1331);
    go(x, 11); go(y, 11); go(z, 11); go(t, 11);
    tot += (x == 1) + (y == 1) + (z == 1) + (t == 1);
    q -= 4;
  }
  while (q--) {
    long long x; cin >> x;
    go(x, 2); go(x, 3); go(x, 5); go(x, 7); go(x, 11); 
    tot += (x == 1);
  }
  cout << tot << '\n';
  return 0;
}