![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
矩阵乘法
andyc_03
这个作者很懒,什么都没留下…
展开
-
【矩阵乘法】 P1962 斐波那契数列
由于斐波那契数列的性质,我们知道f[i]=f[i-1]+f[i-2] 这里按照矩阵的形式写[f[i],f[i+1]]=[f[i+1],f[i+2]] 所以,想要快速推出f[n],那就可以把,平方n-1次,输出右下角的数字 这里计算用到了快速幂 #include<bits/stdc++.h> using namespace std; long long n; const int mod=1e9+7; struct juzhen { unsigned long long a[3][.原创 2020-07-20 16:17:44 · 157 阅读 · 0 评论 -
【矩阵乘法】 P1939 【模板】矩阵加速(数列)
这道题的思路与 P1962 斐波那契数列 基本一致,推出矩阵,然后快速幂即可 #include<bits/stdc++.h> using namespace std; int T,n; const int mod=1e9+7; struct juzhen { long long a[4][4]; }ans,fore,temp; juzhen mul(juzhen xa, juzhen xb) { juzhen cnt; for(int i=1;i<=3;i++) for(in原创 2020-07-20 23:31:11 · 117 阅读 · 0 评论