矩阵连乘
Keep_Trying_Go
无
展开
-
矩阵连乘问题算法
#include<iostream> #include<algorithm> #include<cstring> const int maxn=505; using namespace std; int s[maxn][maxn]; int m[maxn][maxn]; int N; void MAxtrai(int n,int p[]){ for(int i=1;i<=n;i++){//单个矩阵相乘,所需数乘次数为零 m[i][i]=0; s[i]..原创 2021-05-02 00:00:51 · 512 阅读 · 0 评论 -
HDU1575
矩阵快速幂的使用(模版): #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; const ll mod=9973; const ll maxx=1e2+7; ll ax,bx; struct node{ ll p[11][11]; }ans,res; node mul(node a,node b){ node temp;原创 2021-03-01 12:30:55 · 140 阅读 · 0 评论 -
HDU1005
矩阵快速幂: #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; const int mod=7; const int N=3; int A,B,n; struct node{ int p[N][N]; }ans,res; node pow_node(node a,node b){ node temp; for(int原创 2021-03-01 12:29:47 · 60 阅读 · 0 评论 -
poj3734
矩阵快速幂的使用,这个构造矩阵是看了网上大佬的推导过程,其他的就是一些固定的模版了: #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; const ll mod=1e4+7; const int N=3; ll a,b,n; struct node{ ll p[N][N]; }ans,res; node pow_node(原创 2021-03-01 12:28:42 · 83 阅读 · 0 评论 -
poj3070
矩阵快速幂: #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; const ll mod=10000; const ll maxx=1e9+7; ll n; struct node{ ll p[2][2]; }ans,res; node pow_node(node ax,node bx){ node temp; for原创 2021-03-01 12:26:30 · 232 阅读 · 0 评论 -
poj1651(矩阵连乘)
矩阵连乘算法:采用动态规划m[i][j]记录最优解值,s[i][j]记录最优解。 #include<iostream> #include<algorithm> #include<cstring> const int maxn=505; using namespace std; int s[maxn][maxn]; int m[maxn][maxn]; int a[maxn]; int p[maxn]; int N; struct node{ int x,y; }; vo原创 2021-02-24 00:01:43 · 370 阅读 · 0 评论 -
HDU4549(矩阵快速幂+快速幂)
f(n)=a^f(n-1) + b^f(n-2):计算矩阵部分用矩阵快速幂;计算a的幂次和b的幂次用快速幂。 #include<iostream> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long ll; const int maxx=2; const ll mod=1e9+7; ll a,b,n; struct mt{ l原创 2021-02-24 00:03:36 · 121 阅读 · 0 评论 -
HDU4920(矩阵连乘)
就是两个矩阵相乘,时间消耗有点大: #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<cstdio> using namespace std; const int maxx=1005; const int mod=3; int matrix[maxx][maxx]; int a[maxx][maxx]; int b[maxx][maxx原创 2021-02-24 00:04:21 · 150 阅读 · 0 评论