Cod sursa(job #2783494)
Utilizator | Data | 14 octombrie 2021 16:10:17 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int nz(long long n) {
int p = 5;
int s = 0;
while (p <= n) {
s += n / p;
p *= 5;
}
return s;
}
int main() {
int c = 5;
int p;
fin >> p;
while (nz(c) <= p) {
c += 5;
}
if (nz(c) != p)
fout << -1;
else
fout << c - 5;
}