Cod sursa(job #2781406)
Utilizator | Data | 9 octombrie 2021 13:29:38 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 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;
for(x=5;nr5<p;x+=5)
{
int copx=x;
while(copx!=0 && copx%5==0)
{
copx/=5;
nr5++;
}
fout<<nr5<<" ";
}
if(nr5==p)
{
fout<<x;
}
else
{
fout<<-1;
}
}
return 0;
}