Pagini recente » Cod sursa (job #2390638) | Cod sursa (job #1764451) | Cod sursa (job #814889) | Cod sursa (job #2922815) | Cod sursa (job #1942052)
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int main(void)
{
int ret = 0;
FILE *fin = NULL;
FILE *fout = NULL;
fin = fopen("fact.in", "r");
if (fin == NULL) {
ret = -1;
goto exit;
}
fout = fopen("fact.out", "w");
if (fout == NULL) {
ret = -1;
goto exit;
}
int32_t p;
if (fscanf(fin, "%" PRIu32, &p) != 1) {
ret = -1;
goto exit;
}
int32_t pp = 0;
int32_t ppp = 0;
while (pp < p) {
pp++;
ppp++;
int32_t pppp = ppp;
while (pppp % 5 == 0) {
pppp /= 5;
pp++;
}
}
if (pp != p) {
fprintf(fout, "-1");
} else {
if (p == 0) {
fprintf(fout, "1");
} else {
fprintf(fout, "%" PRIu32, ppp * 5);
}
}
exit:
if (fin != NULL) {
fclose(fin);
}
if (fout != NULL) {
fclose(fout);
}
return ret;
}