Cod sursa(job #2188390)
Utilizator | Raul Somesan raulsomesan | Data | 27 martie 2018 09:27:10 |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | bpc9 | Marime | 0.57 kb |
#include <iostream>
#include <fstream>
using namespace std;
int fact(int n)
{
int p=1;
for(int i=1;i<=n;++i)
p=p*i;
return p;
}
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
fin>>p;
int gasit=0, n=1;
while(gasit==0)
{
int k=0;
while(n%10==0)
++k;
if(k==p)
{
fout<<n;
gasit=1;
}
else if(k>p)
{
fout<<"-1";
gasit=1;
}
else
++n;
}
}