Mai intai trebuie sa te autentifici.
Cod sursa(job #397783)
| Utilizator | Data | 17 februarie 2010 15:02:57 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <stdio.h>
int main()
{
long long s,m;
long a=0,b=500,x=250,p;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%ld",&p);
while(a<b-1){
s=0;
m=5;
while(m<=x){
s=s+x/m;
m=m*5;
}
//printf("%lld ",s);
if(s>p){
b=x;
//printf(" 1 ");
x=(a+b)/2;
}
if(s<p){
a=x;
//printf("1 ");
x=(a+b)/2;
}
if(s==p){
break;
}
}
printf("%ld",x-x%5);
return 0;
}
