Cod sursa(job #2781408)
Utilizator | Data | 9 octombrie 2021 13:36:33 | |
---|---|---|---|
Problema | Factorial | Scor | 45 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin ("fact.in");
ofstream fout ("fact.out");
int p,x,nr5=0;
fin>>p;
if(p==0)
{
fout<<1;
}
else
{
nr5=0;
x=0;
while(nr5<p)
{ x+=5;
int copx=x;
while(copx!=0 && copx%5==0)
{
copx/=5;
nr5++;
}
}
if(nr5==p)
{
fout<<x;
}
else
{
fout<<-1;
}
}
return 0;
}