Pagini recente » Cod sursa (job #2196720) | Cod sursa (job #1393844) | Cod sursa (job #963072) | Cod sursa (job #798907) | Cod sursa (job #1799748)
#include <fstream>
using namespace std;
ifstream cin("fact.in");
ofstream cout("fact.out");
void xf(int x, int &c) // x = (5 ^ c) * ...
{
c=0;
while (x % 5 == 0)
{
c++;
x=x/5;
}
}
main()
{
int nz,zr=0,fc=0,x; // nz - numarul de zerouri, fc - x! = 5^fc * ?, zr - zerourile lui x factorial
cin >> nz;
if (nz==0) cout << 1;
else
for (x=5; zr<=nz; x+=5)
{
xf(x,fc);
if (zr+fc>nz)
{
cout << -1;
zr=nz+1;
}
else
if (zr+fc==nz)
{
cout << x ;
zr = nz + 1;
}
else zr+=fc;
}
}