Cod sursa(job #1521073)
Utilizator | Data | 9 noiembrie 2015 21:23:11 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
int p, i, n, a;
ifstream f("fact.in");
ofstream g("fact.out");
f >> p;
n = 5 * p;
b = 5;
while (n > 5 * b) {
a = b;
while ((a / 5) % 5 == 0) {
a /= 5; n -= 5; }
}
if (n % 5 == 0) g << -1;
else g << n;
g << n;
f.close ();
g.close ();
return 0;
}