Cod sursa(job #542108)
| Utilizator | Data | 25 februarie 2011 19:59:28 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.7 kb |
#include <stdio.h>
int fact (int n)
{
int i, a, b, c=0;
for (i=1; i<=n; i++) {
a=i;
b=0;
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=100;
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;
}
