Pagini recente » Cod sursa (job #1228233) | Cod sursa (job #856990) | Cod sursa (job #2087772) | Cod sursa (job #843379) | Cod sursa (job #652491)
Cod sursa(job #652491)
#include <cstdio>
unsigned p;
unsigned cinci(int x)
{
int p=5, ret=0;
while (p<=x)
{
ret+=x/p;
p*=5;
}
return ret;
}
int DeI(int l, int r)
{
int mij, x;
if (l<=r)
{
mij=(l+r)/2;
x=cinci(mij);
if (x==p) return mij/5*5;
if (x>p) return DeI(l, mij-1);
else return DeI(mij+1, r);
}
return -1;
}
int main()
{
// freopen("fact.in", "r", stdin);
// freopen("fact.out", "w", stdout);
unsigned n;
scanf("%u", &p);
if (!p) printf("1");
else printf("%d", DeI(1, p*5));
}