Pagini recente » Cod sursa (job #385466) | Cod sursa (job #2276883) | Cod sursa (job #12261) | Cod sursa (job #2345664) | Cod sursa (job #94853)
Cod sursa(job #94853)
#include <stdio.h>
#include <math.h>
long long p;
long nr_cf(long a)
{
long nr5=0;
for ( long i=5;i<=a;i+=5)
{
long j=i;
while ((j%5==0)&&(j!=0))
{
j/=5;
nr5++;
}
}
return nr5;
}
void verificare (double a)
{
int i=int(a);
while (nr_cf(i-1)==p)
i--;
printf("%d",i);
}
void caut_bin(long x, long y)
{
long s=(x+y)/2;
long long k=nr_cf(s);
if (k<p)
{
caut_bin(s,y);
return;
}
if (k>p)
{
caut_bin(x,s);
return;
}
if (k==p)
verificare(s);
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%lld",&p);
caut_bin(1,2000000000);
fclose(stdout);
return 0;
}