Pagini recente » Cod sursa (job #847229) | Cod sursa (job #1818813) | Cod sursa (job #2745099) | Cod sursa (job #1097942) | Cod sursa (job #582852)
Cod sursa(job #582852)
#include <cstdio>
using namespace std;
int p;
int nrde0(long long x)
{
int n=x,ok=0;
while(n/5!=0)
{
n/=5;
ok+=n;
}
return ok;
}
int main()
{
long long i,n,ok;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
if(p==0)
{
printf("1");
return 0;
}
long long step;
for(step=1;step<1000000000;step<<=1);
for(i=1000000000;step;step>>=1)
if(i-step>0&&nrde0(i-step)>=p)i-=step;
if(nrde0(i)==p)
printf("%lld\n",i);
else printf("-1\n");
fclose(stdout);
return 0;
}