Cod sursa(job #1720568)
| Utilizator | Data | 22 iunie 2016 20:14:55 | |
|---|---|---|---|
| Problema | Factorial | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <iostream>
#include <fstream>
using namespace std;
long pow5(long);
int main()
{
long p;
long i,n,x;
n = 1;
i = 1;
ifstream fin("fact.in");
ofstream fout("fact.out");
fin >> p;
while (p > 0){
n = i * 5;
x = pow5(i);
p = p -x -1;
i++;
}
if (p == 0)
fout << n;
else fout << -1;
return 0;
}
long pow5(long x){
long exp = 0;
while (x % 5 == 0){
exp++;
x = x/5;
}
return exp;
}
