Mai intai trebuie sa te autentifici.
Cod sursa(job #2783490)
Utilizator | Data | 14 octombrie 2021 16:06:31 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream cin("fact.in");
ofstream cout("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;
cin >> p;
while (nz(c) <= p) {
c += 5;
}
if (nz(c) != p)
cout << -1;
else
cout << c - 5;
}