Cod sursa(job #582848)
Utilizator | Data | 16 aprilie 2011 10:02:01 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <cstdio>
using namespace std;
int p;
int cauta_b(int l,int r)
{
int k=(l+r)/2,n=k,ok=0;
while(n/5!=0)
{
n/=5;
ok+=n;
}
if(ok==p)
return k;
else if(ok>p) cauta_b(l,k);
else cauta_b(k+1,r);
}
int main()
{
int i,n,ok;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
if(p==0)
{
printf("1");
return 0;
}
n=cauta_b(p,100000000);
printf("%d",n);
fclose(stdout);
return 0;
}