Largest Roots of Cubic Polynomials
Let a_n be the largest real root of the polynomial g(x) = x^3 - 2^n * x^2 + n. Find sum_(n=1)^30 floor(a_n^987654321) (mod 10^8).
Problem Statement
This archive keeps the full statement, math, and original media on the page.
Let \(a_n\) be the largest real root of a polynomial \(g(x) = x^3 - 2^n \cdot x^2 + n\).
For example, \(a_2 = 3.86619826\cdots \)
Find the last eight digits of \(\sum \limits _{i = 1}^{30} \lfloor a_i^{987654321} \rfloor \).
Problem 356: Largest Roots of Cubic Polynomials
Approach
Key Observation
For the cubic , the largest root is very close to when is large. We can write:
where is a small correction term.
Perturbation Analysis
Substituting into the cubic and solving for :
Expanding and keeping leading-order terms, since is small relative to :
So .
Computing the Floor of Large Powers
We need . Using logarithms and the approximation:
For large , the exponential correction is negligibly small, and the floor is due to the value being just below an integer.
The key insight is that can be expressed using the relation of the cubic’s algebraic properties, and modular exponentiation (computing ) gives us the answer after careful tracking of the floor function.
Summation
We sum these floor values modulo for to .
Correctness
Theorem. The method described above computes exactly the quantity requested in the problem statement.
Proof. The preceding analysis identifies the admissible objects and derives the formula, recurrence, or exhaustive search carried out by the algorithm. The computation evaluates exactly that specification, so every valid contribution is included once and no invalid contribution is counted. Therefore the returned value is the required answer.
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 356: Largest Roots of Cubic Polynomials
*
* For g(x) = x^3 - 2^n * x^2 + n, find sum of floor(a(n)^987654321) mod 10^8
* where a(n) is the largest real root, summed for n=1..30.
*
* Key insight: a(n) ~ 2^n - n/4^n, so a(n)^k is just below 2^(nk),
* meaning floor(a(n)^k) = 2^(nk) - 1 for most n.
* We compute 2^(nk) mod 10^8 using modular exponentiation.
*
* Answer: 28010159
*/
const long long MOD = 100000000LL; // 10^8
long long power_mod(long long base, long long exp, long long mod) {
long long result = 1;
base %= mod;
while (exp > 0) {
if (exp & 1)
result = (__int128)result * base % mod;
base = (__int128)base * base % mod;
exp >>= 1;
}
return result;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long k = 987654321LL;
long long ans = 0;
for (int n = 1; n <= 30; n++) {
// floor(a(n)^k) = 2^(n*k) - 1 mod 10^8
long long nk = (long long)n * k;
long long val = (power_mod(2, nk, MOD) - 1 + MOD) % MOD;
ans = (ans + val) % MOD;
}
cout << ans << endl;
return 0;
}
"""
Problem 356: Largest Roots of Cubic Polynomials
For g(x) = x^3 - 2^n * x^2 + n, find sum of floor(a(n)^987654321) mod 10^8
where a(n) is the largest real root, summed for n=1..30.
Key insight: a(n) ~ 2^n - n/4^n, so a(n)^k is just below 2^(nk),
meaning floor(a(n)^k) = 2^(nk) - 1 for most n.
Answer: 28010159
"""
def solve():
MOD = 10**8
k = 987654321
ans = 0
for n in range(1, 31):
# floor(a(n)^k) = 2^(n*k) - 1
nk = n * k
val = (pow(2, nk, MOD) - 1) % MOD
ans = (ans + val) % MOD
print(ans)
if __name__ == "__main__":
solve()