Pagini recente » Rating Oliver (Oliver) | Cod sursa (job #1448901) | Cod sursa (job #690655) | Cod sursa (job #1361938) | Cod sursa (job #1799850)
#include <fstream>
using namespace std;
ifstream cin("fact.in");
ofstream cout("fact.out");
int xf(int x) // x = (5 ^ c) * ...
{
int c=0;
while (x % 5 == 0)
{
c++;
x=x/5;
}
return c;
}
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=1; zr<=nz; x++)
{
fc=xf(x)+1;
if (zr+fc>nz)
{
cout << -1;
zr=nz+1;
}
else
if (zr+fc==nz)
{
cout << x ;
zr = nz + 1;
}
else zr+=fc;
}
}