Fixed the no output when given a pair that cannot be computed. Also added more debug information.
Stergios Upload Compile Checker / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
metallaxis committed 2026-07-05 06:52:11 +03:00
1 parent fa7aa240e1
commit 067e9bd7fc
4 files changed
+150 -16

No files matched your search

+19 -10
View File
@@ -81,7 +81,11 @@ static bool bfs(int128_t* sum, int128_t gcd,
}
if (!found) {
if (print_mode == 1) printf("No solution found.\n");
fprintf(output, "No solution found for (");
fprint_int128(output, a0); fprintf(output, ", ");
fprint_int128(output, b0); fprintf(output, ", ");
fprint_int128(output, c0);
fprintf(output, ".\n");
return false;
}
@@ -125,15 +129,20 @@ static bool bfs(int128_t* sum, int128_t gcd,
}
} else if (print_mode == 3) {
if (output) {
fprint_int128(output, a0 * gcd); fprintf(output, " ");
fprint_int128(output, b0 * gcd); fprintf(output, " ");
fprint_int128(output, c0 * gcd); fprintf(output, " ");
int128_t a = a0 * gcd, b = b0 * gcd, c = c0 * gcd;
int128_t k = mysqrt_uint128(a * a + b * b + c * c - 2 *a * b - 2 * b * c - 2 * c * a);
fprint_int128(output, a); fprintf(output, " ");
fprint_int128(output, b); fprintf(output, " ");
fprint_int128(output, c); fprintf(output, " ");
fprint_int128(output, max_moves); fprintf(output, " ");
fprint_int128(output, c0 * gcd); fprintf(output, " ");
fprint_int128(output, gcd2(a0 * gcd, c0 * gcd)); fprintf(output, " ");
fprint_int128(output, gcd2(b0 * gcd, c0 * gcd)); fprintf(output, " ");
fprint_int128(output, (c0 * gcd) % (b0 * gcd)); fprintf(output, " ");
fprint_int128(output, (c0 * gcd) % (a0 * gcd)); fprintf(output, " ");
fprint_int128(output, gcd2(a, c)); fprintf(output, " ");
fprint_int128(output, gcd2(b, c)); fprintf(output, " ");
fprint_int128(output, c % b); fprintf(output, " ");
fprint_int128(output, c % a); fprintf(output, " ");
fprint_int128(output, k); fprintf(output, " ");
fprint_int128(output, c - a - b - k); fprintf(output, " ");
fprint_int128(output, c - a - b + k); fprintf(output, " ");
fprintf(output, "%s", k < 2 * (int128_t)mysqrt_uint128(a * b) ? "True" : "False");
fprintf(output, "\n");
}
}
@@ -148,6 +157,6 @@ static bool bfs(int128_t* sum, int128_t gcd,
bool solve(int128_t* sum, int128_t gcd,
int128_t a0, int128_t b0, int128_t c0, int print_mode, FILE* output) {
/* Fallback to BFS */
/* Execute to BFS */
return bfs(sum, gcd, a0, b0, c0, print_mode, output);
}