洛谷P1939题解

题面

观察原递推式, \(f_i=1\times f_{i-1}+0\times f_{i-2}+1\times f_{i-3}\)
所以

\[\begin{aligned} f_i &= 1\times f_{i-1}+0\times f_{i-2}+1\times f_{i-3}, \\ f_{i-1}&=1\times f_{i-1}+0\times f_{i-2}+0\times f_{i-3}, \\ f_{i-2}&=0\times f_{i-1}+1\times f_{i-2}+0\times f_{i-3} \\ \end{aligned} \]

所以

\[\begin{bmatrix} f_i&\\ f_{i-1}&\\ f_{i-2}& \end{bmatrix} = \begin{bmatrix} f_{i-1}&\\ f_{i-2}&\\ f_{i-3}& \end{bmatrix} \times \begin{bmatrix} 1&0&1\\ 1&0&0\\ 0&1&0 \end{bmatrix} \]

于是我们构造出的矩阵为

\[\begin{bmatrix} 1&0&1\\ 1&0&0\\ 0&1&0 \end{bmatrix}\]

代码

posted @ 2021-08-19 17:59  Chiimo  阅读(8)  评论(0编辑  收藏  举报