Cod sursa(job #74625)
| Utilizator | Data | 26 iulie 2007 19:34:46 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include<stdio.h>
int p,n;
void citire(){
freopen("fact.in","r",stdin);
scanf("%d",&p);
}
int rezolvare(){
int k=1,put=0;
if(p==0)
return 1;
int aux=p;
while(aux>5){
aux/=5;
put++;
}
for(int i=1;i<=put;i++){
p-=k;
k*=5;
}
return p*5;
}
void afisare(){
freopen("fact.out","w",stdout);
printf("%d",rezolvare());
fclose(stdout);
}
int main(){
citire();
afisare();
return 0;
}
