Pagini recente » Cod sursa (job #2342317) | Cod sursa (job #370587) | Cod sursa (job #1587458) | Cod sursa (job #1831862) | Cod sursa (job #1942013)
#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;
}
int32_t p;
if (fscanf(fin, "%" PRIu32, &p) != 1) {
ret = -1;
goto exit;
}
uint32_t n = 1;
while (p > 0) {
n++;
uint32_t nn = n;
while (nn % 5 == 0) {
nn /= 5;
p--;
}
}
fout = fopen("fact.out", "w");
if (fout == NULL) {
ret = -1;
goto exit;
}
if (p < 0) {
fprintf(fout, "%d", -1);
} else {
fprintf(fout, "%" PRIu32, n);
}
exit:
if (fin != NULL) {
fclose(fin);
}
if (fout != NULL) {
fclose(fout);
}
return ret;
}