Cod sursa(job #2069680)
Utilizator | Data | 18 noiembrie 2017 18:28:05 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
using namespace std;
ifstream f ("fact.in");
ofstream g ("fact.out");
long long P, N, nrz, ok, aux;
int main ()
{
f>>P;
if (P==0)
g<<"1";
else
{
for (N=5; ok==0 && nrz<P; N=N+5)
{
aux=N;
while (aux%5==0)
{
aux=aux/5;
nrz++;
}
if (nrz==P)
ok=1;
}
if (ok==1)
g<<N-5;
else
g<<"-1";
}
f.close ();
g.close ();
return 0;
}