Fermat-like Equations
Count tuples (a, b, c, e, f) with a^e + b^e = c^f, 0 < a < b, e >= 2, f >= 3, c^f <= N. Given: F(10^3) = 7, F(10^5) = 53, F(10^7) = 287. Find F(10^18).
Problem Statement
This archive keeps the full statement, math, and original media on the page.
If a triple of positive integers \((a, b, c)\) satisfies \(a^2+b^2=c^2\), it is called a Pythagorean triple. No triple \((a, b, c)\) satisfies \(a^e+b^e=c^e\) when \(e \ge 3\) (Fermat’s Last Theorem). However, if the exponents of the left-hand side and right-hand side differ, this is not true. For example, \(3^3+6^3=3^5\).
Let \(a, b, c, e, f\) be all positive integers, \(0 < a < b\), \(e \ge 2\), \(f \ge 3\) and \(c^f \le N\). Let \(F(N)\) be the number of \((a, b, c, e, f)\) such that \(a^e+b^e=c^f\). You are given \(F(10^3) = 7\), \(F(10^5) = 53\) and \(F(10^7) = 287\).
Find \(F(10^{18})\).
Problem 678: Fermat-like Equations
Mathematical Analysis
Case Analysis by
The dominant cases are small and , since larger exponents yield fewer solutions:
Case : . This requires to be a sum of two squares, which (by Fermat’s theorem) means every prime dividing appears to an even power.
Theorem (Sum of Two Squares). is a sum of two squares iff every prime appears to an even power in the factorization of .
Case : . Similar analysis with .
General: For each pair , enumerate with , check if is a sum of -th powers.
Parameterization for
When : . Using Gaussian integers: where . Factor in to find all representations.
The number of representations of as with is related to minus the diagonal.
Enumeration Bounds
For :
- :
- :
- :
- :
For each and , compute and count representations as .
Concrete Examples
| ? | Need to verify |
Small cases for : enumerate all with .
Derivation
Editorial
We iterate over each (since ). We then iterate over each (until ). Finally, count pairs with , .
Pseudocode
For each $f = 3, 4, \ldots, 59$ (since $2^{59} < 10^{18} < 2^{60}$):
Compute $M = c^f$
For each $e = 2, 3, \ldots$ (until $2^e > M$):
Count pairs $(a, b)$ with $a^e + b^e = M$, $0 < a < b$
Sum all valid tuples
Counting Sum-of-Powers Representations
For with : since and , we have . For each , check if is a perfect -th power.
For : use the sum-of-two-squares decomposition via prime factorization in .
Proof of Correctness
The enumeration is exhaustive: all valid pairs are checked, and for each, all valid values are enumerated. The inner loop checks all possible values. No solutions are missed because the bounds on and are exact.
Complexity Analysis
- Outer loop: .
- Inner loop per : For , via Gaussian integer factorization. For , .
- Total: dominated by case: … but with much smaller constant.
In practice, for : values of for , each taking with precomputed factorizations.
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
/*
* Problem 678: Fermat-like Equations
*
* 1. Implement the mathematical framework described above.
* 2. Optimize for the target input size.
* 3. Verify against known test values.
*/
int main() {
printf("Problem 678: Fermat-like Equations\n");
// Enumerate perfect powers, Pythagorean-like parameterization for each (e,f) pair
int N = 100;
long long total = 0;
for (int n = 1; n <= N; n++) {
total += n; // Replace with problem-specific computation
}
printf("Test sum(1..%d) = %lld\n", N, total);
printf("Full implementation needed for target input.\n");
return 0;
}
"""
Problem 678: Fermat-like Equations
"""
print("Problem 678: Fermat-like Equations")
# Core computation
N = 100 # Small test case
values = list(range(1, N + 1)) # Placeholder for problem-specific computation
# The full solution implements: Enumerate perfect powers, Pythagorean-like parameterization for each (e,f) pair
print(f"Computed {len(values)} values")
print(f"Sum = {sum(values)}")
plot_data = [values, values, values, values]