Cod sursa(job #2524294)

Utilizator iancupoppPopp Iancu Alexandru iancupopp Data 15 ianuarie 2020 12:51:22
Problema Factorial Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>

using namespace std;

ifstream in ("fact.in");
ofstream out ("fact.out");

const int VM = 5*1e8;

int nr0 (int n) {
  int nr;
  nr = 0;
  while (n >= 5)
    nr += (n /= 5);
  return nr;
}

int cbin (int p) {
  int st, dr, m;
  st = 1; dr = VM;
  while (st < dr) {
    m = (st + dr) / 2;
    if (nr0 (m) >= p)
      dr = m;
    else
      st = m + 1;
  }
  return st;
}

int main () {
  int p;
  in >> p;
  out << cbin (p);
  return 0;
}