Pagini recente » Cod sursa (job #133147) | Cod sursa (job #2265461) | Cod sursa (job #565746) | Cod sursa (job #2813745) | Cod sursa (job #1398680)
#include <iostream>
#include <fstream>
using namespace std;
long i,y,x,p,nr=0,j;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
if (p==0) {g<<1;return 0;}
else
x=p*4+(p*5-p*4)/2;
for (i=1;i<=x;i++)
{
y=i;
while (y%5==0)
{
nr++;
y=y/5;
}
}
if (nr==p) {g<<x;return 0;}
else
if (nr<p) for (i=x;i<=p*5;i++)
{
nr=0;
y=x;
for (j=1;j<=i;j++)
{
while (y%5==0)
{
nr++;
y=y/5;
}
}
if (nr==p) {g<<x;return 0;}
}
else
if (nr>p) for (i=p*4;i<=x;i++)
{
nr=0;
y=x;
for (j=1;j<=i;j++)
{
while (y%5==0)
{
nr++;
y=y/5;
}
}
if (nr==p) {g<<x;return 0;}
}
g<<-1;
return 0;
}