Cod sursa(job #2640633)
| Utilizator | Data | 7 august 2020 02:56:28 | |
|---|---|---|---|
| Problema | Factorial | Scor | 95 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <stdio.h>
int main() {
long int x, aux, x_max, p, s;
FILE *in = fopen("fact.in", "rt");
FILE *out = fopen("fact.out", "wt");
fscanf(in, "%ld", &p);
x = 4 * p;
x_max = 5 * p + 1;
aux = x;
if (p == 0)
x = 1;
else {
while (x < x_max) {
s = 0;
while (aux) {
s += aux/5;
aux /= 5;
}
if (s == p){
break;
} else if (s < p) {
x++;
aux = x;
}
}
if (s != p)
x = -1;
}
fprintf(out, "%ld\n", x);
fclose(in);
fclose(out);
return 0;
}