Cod sursa(job #150259)
| Utilizator | Data | 6 martie 2008 19:51:37 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<stdio.h>
#include<iostream.h>
long getz(long x){
long a=(x/5+x/25);
return a;
}
int main(void){
long p,i,n=0;
FILE *in=fopen("fact.in","rt"),*out=fopen("fact.out","w+");
fscanf(in,"%ld",&p);
long l=0,r=100000000,m=(l+r)/2;
while(l<r){
m=(l+r)/2;
if(getz(m)==p) {n=m;break;}
else if (getz(m)<p) l=m;
else if (getz(m)>p) r=m;
}
// if(i==100000) fprintf(out,"%ld",i);
fprintf(out,"%ld",n-1);
}