跳到正文

题解

题解 P5110 【块速递推】

ezoixx130约 4 分钟
原文
文章信息与版本

文章信息

发布
2018年12月23日
收录
2026年3月18日
更新
2026年11月18日
篇幅
约 4 分钟
题目
P5110

版本

  1. v2当前
  2. v1

这里讲一种不用生成函数什么的东西求通项公式的方法:待定系数法

首先 an=233an−1+666an−2,a0=0,a1=1\Large a_n=233a_{n-1}+666a_{n-2},a_0=0,a_1=1

设an+2+pan+1=q(an+1+pan)\Large a_{n+2}+pa_{n+1}=q(a_{n+1}+pa_n)

则p,q\Large p,q 满足q−p=233\Large q-p=233 , pq=666\Large pq=666

即q2−233q−666=0\Large q^2-233q-666=0

解得q=233±569532,p=−233±569532\Large q=\frac{233\pm\sqrt{56953}}{2},p=\frac{-233\pm\sqrt{56953}}{2}

当q=233+569532,p=−233+569532\Large q=\frac{233+\sqrt{56953}}{2},p=\frac{-233+\sqrt{56953}}{2} 时

an+2+−233+569532an+1=233+569532(an+1+−233+569532an)\Large a_{n+2}+\frac{-233+\sqrt{56953}}{2}a_{n+1}=\frac{233+\sqrt{56953}}{2}(a_{n+1}+\frac{-233+\sqrt{56953}}{2}a_n) (①式)

设bn=an+1+−233+569532an\Large b_n=a_{n+1}+\frac{-233+\sqrt{56953}}{2}a_n

则bn+1=an+2+−233+569532an+1\Large b_{n+1}=a_{n+2}+\frac{-233+\sqrt{56953}}{2}a_{n+1}

将上两式代入①式得bn+1=233+569532bn\Large b_{n+1}=\frac{233+\sqrt{56953}}{2}b_n

于是我们知道了{bn}\Large \{b_n\} 是等比数列。

又因为b1=a2+−233+569532a1=233+−233+569532\Large b_1=a_2+\frac{-233+\sqrt{56953}}{2}a_1=233+\frac{-233+\sqrt{56953}}{2}

所以bn=(233+569532)n−1(233+−233+569532)=(233+569532)n\Large b_n=(\frac{233+\sqrt{56953}}{2})^{n-1}(233+\frac{-233+\sqrt{56953}}{2})=(\frac{233+\sqrt{56953}}{2})^n

所以an+1+−233+569532an=(233+569532)n\Large a_{n+1}+\frac{-233+\sqrt{56953}}{2}a_n=(\frac{233+\sqrt{56953}}{2})^n

当q=233−569532,p=−233−569532\Large q=\frac{233-\sqrt{56953}}{2},p=\frac{-233-\sqrt{56953}}{2} 时

同理得到an+1+−233−569532an=(233−569532)n\Large a_{n+1}+\frac{-233-\sqrt{56953}}{2}a_n=(\frac{233-\sqrt{56953}}{2})^n

上两式相减就可以得到56953an=(233+569532)n−(233−569532)n\Large \sqrt{56953}a_n=(\frac{233+\sqrt{56953}}{2})^n-(\frac{233-\sqrt{56953}}{2})^n

an=(233+569532)n−(233−569532)n56953\Large a_n=\frac{(\frac{233+\sqrt{56953}}{2})^n-(\frac{233-\sqrt{56953}}{2})^n}{\sqrt{56953}}

这就已经是这个数列的通项公式了。

但是我们只需要求这个数列在模109+7\Large 10^9+7意义下的值,因此还可以继续推。

我们要求56953\Large \sqrt{56953} 在模109+7\Large 10^9+7意义下的值,就是要找到满足x2≡56953(mod  109+7)\Large x^2 \equiv 56953 (\mod 10^9+7)的x\Large x 。然后我们发现出题人选数选得刚刚好,我们找到了1883058372≡56953(mod  109+7)\Large 188305837^2 \equiv 56953 (\mod 10^9+7) 。

然后就可以推出an≡(233+1883058372)n−(233−1883058372)n188305837(mod  109+7)\Large a_n \equiv \frac{(\frac{233+188305837}{2})^n-(\frac{233-188305837}{2})^n}{188305837} (\mod 10^9+7)

最后得到an=233230706(94153035n−905847205n)(mod  109+7)\Large a_n=233230706(94153035^n-905847205^n) (\mod 10^9+7)

完美!

然后就可以用光速幂每次O(1)O(1) 求答案了。

原文
存档评论25 条抓取于