Cod sursa(job #540777)
| Utilizator | Data | 24 februarie 2011 13:17:39 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <stdio.h>
#include <math.h>
FILE*f = fopen("fact.in","r");
FILE*g = fopen("fact.out","w");
//int v[1000002];
int i,s,j,zero;
long long p,u,m,x;
int main() {
//printf("%d",v[100000]);
fscanf(f,"%d",&x);
p=1; u=1000000002;
while (p<=u){
m = p + (u-p)/2;
//calc cate 0 are la final m!
j=1;
s=0;
while (m/int(pow(5,j)) > 0){
s+=m/int(pow(5,j));
j++;
}
zero=s;
if(zero>=x)
u=m-1;
else
p=m+1;
}
fprintf(g,"%d\n",p);
return 0;
}
