Cod sursa(job #599727)
| Utilizator | Data | 29 iunie 2011 15:15:17 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <stdio.h>
long P, N, N1, P1;
int main() {
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%ld", &P);
if(P == 0){ printf("1"); P1 = -1;}
else {
for(N = 5; N <= P * 5; N += 5) {
N1 = N;
P1 = 0;
while(N1 != 0) {
P1 += N1 / 5;
N1 /= 5;
}
if(P1 == P) {
printf("%ld", N);
P1 = -1;
break;
}
}
}
if(P1 != -1) {
printf("-1");
}
return 0;
}