Cod sursa(job #757721)
Utilizator | Data | 13 iunie 2012 02:44:33 | |
---|---|---|---|
Problema | Factorial | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<stdio.h>
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int p,n,k,x,i;
scanf("%d",&p);
if(p==0) n=1;
else n=0;
do
{
i=0;
k=1;
x=0;
while(x-i+1<=p)
{
k *= 5;
x = 5*x+1;
i++;
}
n += k/5;
p -= x/5;
}while(p>0);
printf("%d\n",n);
return 0;
}