Cod sursa(job #304333)
Utilizator | Data | 12 aprilie 2009 02:27:59 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<stdio.h>
long pcinci(long x)
{long r=0;
while(x%5==0)
{r++;x/=5;}
return r;}
int main()
{long n,p,z=0,x;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%ld",&p);
if(!p)
printf("1\n");
else
{for(n=1;z<p;n++)
z+=pcinci(5*n);
if(z>p)
printf("%-1\n");
if(z==p)
printf("%ld\n",5*(n-1));
}
return 0;}