Cod sursa(job #218632)
| Utilizator | Data | 2 noiembrie 2008 20:23:30 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.41 kb |
/*
* factorial.cpp
*
* Created on: Nov 2, 2008
* Author: stefan
*/
#include<stdio.h>
int main()
{
long int P, N, i;
scanf("%ld", &P);
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
if (P == 0)
{
printf("1");
return 0;
}
for (N = 5; P > 0; N += 5)
{
i = N;
while (i % 5 == 0)
{
--P;
i /= 5;
}
}
if (P)
printf("-1");
else
printf("%ld", N-5);
return 0;
}
