Cod sursa(job #1464450)
Utilizator | Data | 23 iulie 2015 16:08:13 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
main()
{
ifstream f1("fact.in");
ofstream f2("fact.out");
long int n=0, p, pow5=0, k;
f1>>p;
n = 5 * p;
while (n >= 0)
{
k = n;
while (k % 5 == 0){
k = k / 5;
pow5++;
}
n = n - 5;
}
if (pow5 == p) f2 << 5 * p;
else f2 << -1;
}