Pagini recente » Cod sursa (job #2594695) | Cod sursa (job #3240473) | Cod sursa (job #2543523) | Cod sursa (job #2670137) | Cod sursa (job #542125)
Cod sursa(job #542125)
#include <stdio.h>
int fact (int n)
{
int i, j, a, b, c=0;
for (i=5; i<=n; i+=5) {
a=i;
b=0;
j=5;
while (a%j==0) {
b++;
j*=5;
}
/*while (a%5==0) {
b++;
a/=5;
}*/
c+=b;
}
return c;
}
int main ()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
int p, st, dr, t;
scanf("%d", &p);
st=1;
dr=1000000;
while (st<=dr) {
t=(st+dr)/2;
if (p==fact(t)) {
while (p==fact(t)) {
t--;
}
printf ("%d", t+1);
break;
} else if (p<fact(t)) {
dr=t-1;
} else {
st=t+1;
}
}
return 0;
}