Processing math: 100%

一道关于斐波那契序列的题

 

大致意思是定义 $f_0=f_1=1$,$f_i=f_{i-1}+f_{i-2}$
Σni=0fifni

Fn=Σni=0fifni
FnFn1=Σni=0fifniΣn1i=0fifn1i
=f0fn+Σni=1fifniΣn1i=0fifn1i
=f0fn+Σn1i=0fifniΣn1i=0fifn1i
=fn+Σi=0n−1fi(fn−i−fn−1−i)=f_n+\Sigma^{n-1}_{i=0}f_i(f_{n-i}-f_{n-1-i})=fn+Σi=0n1fi(fnifn1i)
=fn+Σi=0n−1fi(fn−i−2)=f_n+\Sigma^{n-1}_{i=0}f_i(f_{n-i-2})=fn+Σi=0n1fi(fni2)
=fn+Fn−2=f_n+F_{n-2}=fn+Fn2

所以,Fn=Fn−1+Fn−2+fnF_n=F_{n-1}+F_{n-2}+f_nFn=Fn1+Fn2+fn
于是,Fn−1=Fn−2+Fn−3+fnF_{n-1}=F_{n-2}+F_{n-3}+f_nFn1=Fn2+Fn3+fnFn−2=Fn−3+Fn−4+fnF_{n-2}=F_{n-3}+F_{n-4}+f_nFn2=Fn3+Fn4+fn,二式三式相加并与一式作差,可消去 fnf_nfn。得到 FFF 的递推式:Fn=2Fn−1+Fn−2−2Fn−3−Fn−4F_n=2F_{n-1}+F_{n-2}-2F_{n-3}-F_{n-4}Fn=2Fn1+Fn22Fn3Fn4,用矩阵加速求即可。

转移矩阵为:
{{2,1,0,0},
{1,0,1,0},
{-2,0,0,1},
{-1,0,0,0}}

初始化:F0=1,F1=2,F2=5,F3=10F_0=1, F_1=2, F_2=5, F_3=10F0=1,F1=2,F2=5,F3=10

 

posted @   no_proper_name_left  阅读(165)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示