Cod sursa(job #259602)
Utilizator | Vlad Schnakovszki shnako | Data | 15 februarie 2009 15:35:01 |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <stdio.h>
long long i, t, p;
int main(void)
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%lld", &p);
if (p==0)
printf("1");
else
for (i=5;;i+=5)
{
p--;
if (i%5==0)
{
t=i;
while (t%5==0)
{
p--;
t/=5;
}
}
if (p==0)
{
printf("%lld", 5*i);
break;
}
else
if (p<0)
{
printf("-1");
break;
}
}
fcloseall();
return 0;
}