Cod sursa(job #414624)
| Utilizator | Data | 10 martie 2010 12:21:19 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <stdio.h>
#define DIM 100001
int n,P;
int s,c;
int p,mij;
long long u;
int main(){
FILE*f1=fopen("fact.in","r");
FILE*f2=fopen("fact.out","w");
fscanf(f1,"%d",&P);
p = P;
u = 5*P;
while(p <= u){
mij = p + (u - p)/2;
s = 0;
c = 5;
while(c <= mij){
s += mij / c;
c *= 5;
}
if(s >= P)
u = mij - 1;
else
p = mij + 1;
}
if(P == 0)
fprintf(f2,"1");
else
fprintf(f2,"%d",p);
fclose(f1);
fclose(f2);
return 0;
}
