Pagini recente » Cod sursa (job #334466) | Cod sursa (job #516944) | Cod sursa (job #957036) | Cod sursa (job #2336768) | Cod sursa (job #358056)
Cod sursa(job #358056)
#include<stdio.h>
int zero(int n)
{
int nr=0;
while(n)
{
nr+=n/5;
n/=5;
}
return nr;
}
int caut(int x)
{
int pas, i;
pas = 1<<30;
for(i=0; pas; pas>>=1)
if(zero(i+pas)<=x)
i=i+pas;
if (zero (i) != x)
return -1;
return i-4;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int p,n;
scanf("%d",&p);
if (p == 0)
printf ("1");
else
{
n=caut(p);
printf("%d",n);
}
return 0;
}