Cod sursa(job #2640557)
| Utilizator | Data | 6 august 2020 20:21:39 | |
|---|---|---|---|
| Problema | Factorial | Scor | 85 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <stdio.h>
int main() {
int p, x, aux, x_max, s;
FILE *in = fopen("fact.in", "rt");
FILE *out = fopen("fact.out", "wt");
fscanf(in, "%d", &p);
x = 4 * p;
x_max = 5 * p + 1;
aux = x;
if (p == 1)
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, "%d\n", x);
fclose(in);
fclose(out);
return 0;
}