矩阵快速幂
文章平均质量分 60
矩阵快速幂
西伯利亚松鼠
退役ACMer,退役MOer
展开
-
Chinese Rings HDU-2842 矩阵快速幂
Chinese Rings SOLUTION f[n]=2f[n−2]+f[n−1]+1f[n]=2f[n-2]+f[n-1]+1f[n]=2f[n−2]+f[n−1]+1 [121100001]n−2\left[ \begin{matrix} 1 & 2 & 1 \\1 & 0 & 0 \\0 & 0 & 1 \end{matrix} \right]^{n-2}⎣⎡110200101⎦⎤n−2*[f[2]f[1]1]\left[\b原创 2021-04-07 11:08:09 · 798 阅读 · 0 评论 -
Tr A HDU-1575 矩阵快速幂
Tr A SOLUTION 模板题,计算对角线和 CODE /*SiberianSquirrel*/ /*CuteKiloFish*/ #include<bits/stdc++.h> using namespace std; const int MOD = 9973; int n, k; struct Matrix { static const int M = 10; int mx[M][M]; Matrix(){ memset(mx, 0, si原创 2021-04-07 10:35:19 · 661 阅读 · 0 评论 -
Fast Matrix Calculation HDU-4965 矩阵快速幂
Fast Matrix Calculation SOLUTION 已知An∗k,Bk∗n,n<1000,k<6,要求(AB)n2有,已知A_{n*k},B_{k*n},n<1000,k<6,要求(AB)^{n^2}有,已知An∗k,Bk∗n,n<1000,k<6,要求(AB)n2有, (AB)n2=A∗(BA)n2−1∗B,其中(BA)k∗k(AB)^{n^2}=A*(BA)^{n^2-1}*B,其中(BA)_{k*k}(AB)n2=A∗(BA)n2−1∗B,其中(原创 2021-04-04 23:09:39 · 707 阅读 · 0 评论 -
Matrix multiplication HDU-4920 矩阵
Matrix multiplication SOLUTION 行取元素加速行取元素加速行取元素加速 CODE /*SiberianSquirrel*/ /*CuteKiloFish*/ #include<bits/stdc++.h> using namespace std; const int MOD = 3; int n; int A[801][801], B[801][801], x[801][801]; struct Matrix { static const int M原创 2021-04-04 22:26:41 · 617 阅读 · 0 评论 -
Sequence HDU-6395 整除分块+矩阵快速幂
Sequence SOLUTION eg:P=10,n=12eg:P=10,n=12eg:P=10,n=12 [DCP3100001]\left[ \begin{matrix} D & C & \frac P3 \\1 & 0 & 0 \\0 & 0 & 1 \end{matrix} \right]⎣⎡D10C003P01⎦⎤ * [DCP4100001]2\left[ \begin{matrix} D & C &原创 2021-04-04 21:51:03 · 725 阅读 · 0 评论 -
Arc of Dream HDU-4686 矩阵快速幂
Arc of Dream solution [AxAy000010000ByBx00AxByAyByAyBxAxBx000011]n\left[ \begin{matrix} Ax & Ay & 0 & 0 & 0 \\0 & 1 & 0 & 0 & 0 \\0 & By & Bx & 0 & 0 \\AxBy & AyBy & AyBx & AxBx & 0 \\0原创 2021-04-04 18:18:02 · 650 阅读 · 0 评论 -
Fibonacci Again HDU-1021 矩阵快速幂
Fibonacci Again code /*SiberianSquirrel*/ /*CuteKiloFish*/ #include<bits/stdc++.h> using namespace std; const int MOD = 3; int A, B, n; typedef struct Matrix { int mx[2][2]; void Init(int a,int b) { mx[0][0] = a, mx[0][1] = b;原创 2021-04-03 15:46:03 · 687 阅读 · 0 评论 -
Number Sequence HUD-1005 矩阵快速幂
Number Sequence code /*SiberianSquirrel*/ /*CuteKiloFish*/ #include<bits/stdc++.h> using namespace std; const int MOD = 7; int A, B, n; typedef struct Matrix { int mx[2][2]; void Init(int a,int b) { mx[0][0] = a, mx[0][1] = b;原创 2021-04-03 14:22:22 · 640 阅读 · 0 评论