Pagini recente » Cod sursa (job #1950528) | Cod sursa (job #637217) | Cod sursa (job #2973049) | Cod sursa (job #437567) | Cod sursa (job #94866)
Cod sursa(job #94866)
#include <stdio.h>
#include <math.h>
long long p;
long long nr_cf(long long a)
{
long long nr5=0;
for ( long long i=5;i<=a;i+=5)
{
long long j=i;
while ((j%5==0)&&(j!=0))
{
j/=5;
nr5++;
}
}
return nr5;
}
void verificare (long long a)
{
long long i=a;
while (nr_cf(i-1)==p)
i--;
printf("%lld",i);
}
void caut_bin(long long x, long long y)
{
long 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,10000000000);
fclose(stdout);
return 0;
}