Cod sursa(job #2330854)
| Utilizator | Data | 28 ianuarie 2019 21:15:52 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
#include <cmath>
using namespace std;
long long nrz(int n);
int n, j;
int main() {
ifstream ifs("fact.in");
ofstream ofs("fact.out");
ifs >> n;
for (j = 5; nrz(j) <= n; j = j + 5);
if (nrz(j - 5) == n)
ofs << j - 5;
else ofs << -1;
return 0;
}
long long nrz(int n) {
int i = 1;
long long num = 0;
while (n / pow(5, i) != 0) {
num = num + n / pow(5, i);
i++;
}
return num;
}