Cod sursa(job #2689392)

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

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

int main() {
  ifstream cin("dtcsu.in");
  ofstream cout("dtcsu.out");
  string s; getline(cin, s);
  int 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, 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;
}