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 | N = 10**6 |