斐波那契和----“科大讯飞杯”第十七届同济大学程序设计预选赛暨高校网络友谊赛
链接:https://ac.nowcoder.com/acm/contest/5477/J
来源:牛客网
题目描述
Fib(i)表示斐波那契函数,Fib(n)=Fib(n-1)+Fib(n-2),如Fib(1)=1,Fib(2)=1,Fib(3)=2,Fib(4)=3,Fib(5)=5,Fib(6)=8。
给定正整数n和k,求:![This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program.](http://latex.codecogs.com/gif.latex?S%28n%29%3D%5Csum_%7Bi%3D1%7D%5E%7Bn%7D%7Bi%7D%5E%7Bk%7DFib%28i%29)
由于结果太大,你需要把求和的结果对998,244,353取余。
题解:
仔细一看,是找规律题,明显是递推式,可以用杜教BM
有一种思路,用矩阵快速幂加速递推
记
,则
![](https://img2020.cnblogs.com/blog/1301190/202005/1301190-20200510190348764-2028454420.png)
故矩阵可以列为