You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
922 B

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 110;
const int MOD = 1007;
int n = 3;
/*
测试用例
1 2 3
1 2 3
1 2 3
4 5 6
4 5 6
4 5 6
输出结果:
24 30 36
24 30 36
24 30 36
*/
//两个n*n的矩阵
void mul(LL z[][N], LL x[][N], LL y[][N]) {
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
for (int k = 1; k <= n; k++)
z[i][j] = z[i][j] % MOD + x[i][k] * y[k][j] % MOD;
}
LL x[N][N], y[N][N], z[N][N];
int main() {
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
cin >> x[i][j];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
cin >> y[i][j];
mul(z, x, y);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++)
cout << z[i][j] << " ";
cout << endl;
}
return 0;
}