其他分享
首页 > 其他分享> > 欧拉计划

欧拉计划

作者:互联网

\(\texttt{Problem 1}\)

\(\texttt{Describe}\)

在小于 \(10\) 的自然数中,\(3\) 或 \(5\)的倍数有 \(3,5,6\) 和 \(9\),这些数之和是 \(23\)。

求小于 \(1000\) 的自然数中所有 \(3\) 或 \(5\) 的倍数之和。

\(\texttt{Solution}\)

可以考虑容斥,我们定义函数 \(S(x)\) 为小于 \(1000\) 的 \(x\) 的倍数之和。

\[\begin{aligned} S(x)&=\sum_{i=1}^{\lfloor \frac{999}{x} \rfloor} i\cdot x\\ &=x\cdot\sum_{i=1}^{\lfloor \frac{999}{x} \rfloor} i\\ &=\dfrac x2\cdot(1+\lfloor \dfrac {999}{x} \rfloor)\cdot\lfloor \dfrac {999}{x} \rfloor \end{aligned} \]

所以答案等于

\[\text{Answer}=S(3)+S(5)-S(15)=233168 \]

\(\texttt{Problem 2}\)

\(\texttt{Describe}\)

\(\texttt{Fibonacci}\) 数列定义为:

\[f_0=0,f_1=1\\ f_i=f_{i-2}+f{i-1}(i\ge 2) \]

考虑一个 \(\texttt{Fibonacci}\) 数列中不超过四百万的项,求其中为偶数的项之和。

\(\texttt{Solution}\)

考虑生成函数

\[\begin{aligned} &F(x)=\sum_{n=0}^\infty f_nx^n\\ &xF(x)=\sum_{n=1}^\infty f_{n-1}x^n\\ &x^2F(x)=\sum_{n=2}^\infty f_{n-2}x^n\\ \end{aligned} \]

显然有 \(xF(x)+x^2F(x)-f_0x+f_1x+f_0=F(x)=x+xF(x)+x^2F(x)\),易有 \(F(x)=\dfrac{x}{1-x-x^2}\)

因为由几何级数可以得知

\[\sum_{n=0}^\infty a_0r^n=\dfrac{1}{1-r}\qquad|r|\in[0,1) \]

所以想将封闭形式转化为几何级数的和,利用待定系数法分解。

\[F(x)=\dfrac{x}{1-x-x^2}=\dfrac{u}{1-px}+\dfrac{v}{1-qx}=\dfrac{u-uqx+v-vpx}{(1-px)(1-qx)}\\ \]

有方程

\[\begin{cases} pq=-1\\ p+q=1\\ u+v=0\\ uq+vp=-1\\ \end{cases} \]

解得

\[\begin{cases} p=\dfrac{1-\sqrt 5}{2}\\ q=\dfrac{1+\sqrt 5}{2}\\ u=-\dfrac{1}{\sqrt 5}\\ v=\dfrac{1}{\sqrt 5}\\ \end{cases} \]

所以

\[\begin{aligned} F(x) &=\dfrac {1}{\sqrt 5}(\dfrac{1}{1-\frac {1+\sqrt 5}{2}x}-\dfrac{1}{1-\frac {1-\sqrt 5}{2}x})\\ &=\dfrac {1}{\sqrt 5}\left(\sum_{n=0}^\infty\left(\dfrac{1+\sqrt 5}{2}\right)^n-\sum_{n=0}^\infty\left(\dfrac{1-\sqrt 5}{2}\right)^n\right)x^n \end{aligned} \]

所以推得 \(\texttt{Fibonacci}\) 数列的通项公式为

\[f_n=\dfrac{1}{\sqrt 5}\left(\left(\dfrac{1+\sqrt 5}{2}\right)^n-\left(\dfrac{1-\sqrt 5}{2}\right)^n\right) \]

解不等式(下面推导过程中 \(L\) 表示 \(4000000\))

\[f_n\le L\\ \\ \dfrac{1}{\sqrt 5}\left(\left(\dfrac{1+\sqrt 5}{2}\right)^n-\left(\dfrac{1-\sqrt 5}{2}\right)^n\right)\le L\\ \\ \left(\left(\dfrac{1+\sqrt 5}{2}\right)^n-\left(\dfrac{1-\sqrt 5}{2}\right)^n\right)\le\sqrt 5L \]

我们利用二项式定理展开不等式左边

\[\begin{aligned} \left(\left(\dfrac{1+\sqrt 5}{2}\right)^n-\left(\dfrac{1-\sqrt 5}{2}\right)^n\right)&=2^{-n}\left(\sum_{i=0}^n\binom ni \sqrt 5^i-\sum_{i=0}^n\binom ni (-1)^i\sqrt 5^i\right)\\ &=2^{-n}\sum_{i=0}^n\binom ni\sqrt 5^i-(-1)^i\sqrt 5^i\\ &=2^{-n}\sum_{i=0}^{\left\lfloor\frac{n-1}{2}\right\rfloor}2\binom{n}{2i+1}\sqrt 5^{2i+1}\\ &=2^{1-n}\sqrt 5\sum_{i=0}^{\left\lfloor\frac{n-1}{2}\right\rfloor}\binom{n}{2i+1}\sqrt 5^{2i}\\ &=2^{1-n}\sqrt 5\sum_{i=0}^{\left\lfloor\frac{n-1}{2}\right\rfloor}\binom{n}{2i+1}5^{i} \end{aligned} \]

由计算得知 \(n=33\)。
考虑原问题要求偶数,我们研究 \(\texttt{Fibonacci}\) 数列的奇偶性,打表观察规律:

\(i\) \(0\) \(1\) \(2\) \(3\) \(4\) \(5\) \(6\) \(7\) \(8\) \(9\)
\(f_i\) \(0\) \(1\) \(1\) \(2\) \(3\) \(5\) \(8\) \(13\) \(21\) \(34\)
奇偶性 \(\texttt{even}\) \(\texttt{odd}\) \(\texttt{odd}\) \(\texttt{even}\) \(\texttt{odd}\) \(\texttt{odd}\) \(\texttt{even}\) \(\texttt{odd}\) \(\texttt{odd}\) \(\texttt{even}\)

标签:right,dfrac,sum,texttt,sqrt,计划,欧拉,left
来源: https://www.cnblogs.com/JIEGEyyds/p/16597107.html