A=[1,-1,1,-4;5,-4,3,12;2,1,1,11;2,-1,7,-1] E=[1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1] b=[2,4,3,0]' %开始消元过程 for k=1:(length(A)) a=A(k,k) for i=1:(length(A)) A(k,i)=A(k,i)/a E(k,i)=E(k, i)/a end b(k,1)=b(k,1)/ a for i=k+1:(length(A)) c=-A(i,k) for j=1: (lengt
e=sym('e') E=[1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1] E=e.*E A=[1,-1,1,-4;5,-4,3,12;2,1,1,11;2,-1,7,-1] A=A-E Adet=1 %开始消元过程 for k=1:(length(A)) a=A(k,k) Adet = Adet.*a for i=1:(length(A)) A(k,i)=A(k,i)/a end for i=k+1:(length(A)) c=-A(i,k) for j=1: (length
A=[1,-1,1,-4;5,-4,3,12;2,1,1,11;2,-1,7,-1] Adet=1 %开始消元过程 for k=1:(length(A)) a=A(k,k) Adet = Adet.*a for i=1:(length(A)) A(k,i)=A(k,i)/a end for i=k+1:(length(A)) c=-A(i,k) for j=1: (length(A)) A(i,j)=A(i,j)+c.*A(k,j) end end end Adet A = 1 -1 1 -4
题目: The Water Bowls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5013 Accepted: 1960 Description The cows have a line of 20 water bowls from which they drink. The bowls can be either right-side-up (properly oriented to serve refresh
题目链接:https://www.luogu.org/problem/P4783 题意:求矩阵的逆. 思路:高斯消元法求矩阵的逆,n为400,卡常,我是开了O2优化才AC的.. AC代码: #include<cstdio> #include<cctype> #include<algorithm> #define R register int using namespace std; const int maxn=405; const int MOD=1e9+7; int