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