Cod sursa(job #414621)
Utilizator | Data | 10 martie 2010 12:19:42 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<stdio.h>
FILE*f=fopen("fact.in","r");
FILE*g=fopen("fact.out","w");
int P; long long u;
int m,p,x,nr;
int main () {
fscanf(f,"%d",&P);
u=2000000LL*2000000LL;
p=1;
while(p<=u){
m=p+(u-p)/2;
x=5;
nr=0;
while(x<=m){
nr+=m/x;
x*=5;
}
if(nr>=P)
u=m-1;
else
p=m+1;
}
fprintf(g,"%d",p);
fclose(f);
fclose(g);
return 0;
}