Pagini recente » Istoria paginii runda/3243242432/clasament | Statistici raisour (nura_diana) | Istoria paginii runda/simulare-cartita-37/clasament | Monitorul de evaluare | Cod sursa (job #2640558)
#include <stdio.h>
int main() {
int p, s;
long x, aux, x_max;
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 == 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;
}