Cod sursa(job #1042321)
| Utilizator | Data | 26 noiembrie 2013 21:07:38 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.4 kb |
#include<stdio.h>
#include<math.h>
int t,x=0,cp,putere=0,baza,p,j;
FILE *f,*g;
int main ()
{
f=fopen("fact.in","r");
fscanf(f,"%d",&p);
g=fopen("fact.out","w");
if(p==0)fprintf(g,"%d",1);
else{ while(cp!=p){x+=5;putere=0;baza=0;cp=0;
do{baza*=5;putere++;}while(putere<=x);
for(j=1;j<=putere;j++){cp=cp+x/pow(5,j);}}
fprintf(g,"%d",x);}
fclose(f);
fclose(g);
return 0;
}