Cod sursa(job #2188477)
Utilizator | Data | 27 martie 2018 10:17:28 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp | Status | done |
Runda | bpc9 | Marime | 0.68 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
fin>>p;
if(p==0)
fout<<1;
else
{
int x=0;
int k=0;
int semafor=0;
while(k<=p)
{
x=x+5;
int cx=x, ck=0;
while(cx%5==0)
{
++ck;
cx=cx/5;
if(ck>1)
semafor=1;
else
semafor=0;
}
k=k+ck;
}
if(semafor==1)
fout<<-1;
else
fout<<x-5;
}
}