Project Euler 479

Project Euler 479

题目

Roots on the Rise

Let $a_k$, $b_k$, and $c_k$ represent the three solutions (real or complex numbers) to the equation

$\dfrac{1}{x}=\left(\dfrac{k}{x}\right)^2(k+x^2)-kx$.

For instance, for $k=5$, we see that ${a_5, b_5, c_5 }$ is approximately ${5.727244, -0.363622+2.057397i, -0.363622-2.057397i}$.

Let $\displaystyle S(n) = \sum{p=1}^n\sum{k=1}^n(a_k+b_k)^p(b_k+c_k)^p(c_k+a_k)^p$.

Interestingly, $S(n)$ is always an integer. For example, $S(4) = 51160$.

Find $S(10^6) \text{ modulo }1\,000\,000\,007$.

解决方案

经过去分母和移项,原方程转化为$kx^3-k^2x^2+x-k^3=0(x \neq 0)$。

根据该页面关于三元一次方程$ax^3+bx^2+cx+d=0$的韦达定理:

得到:

那么

因此再根据等比数列求和公式,有

代码

1
2
3
4
5
6
7
8
N = 10**6
mod = 10 ** 9 + 7

ans = 0
for k in range(2, N + 1):
ans = (ans - (1 - k * k) * (pow(1 - k * k, N, mod) - 1) % mod * pow(k * k, mod - 2, mod)) % mod
print(ans)

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
Ujimatsu Chiya 微信 微信
Ujimatsu Chiya 支付宝 支付宝