LibreOJ #100. 矩阵乘法
二次联通门 : LibreOJ #100. 矩阵乘法
/* LibreOJ #100. 矩阵乘法 矩阵乘法 注意两个矩阵宽与高相乘的顺序 */ #include <cstdio> #define Max 500 #define Mod 1000000007 int main (int argc, char *argv[]) { static long long a[Max + 1][Max + 1], b[Max + 1][Max + 1]; int N, P, M; scanf("%d %d %d", &N, &P, &M); for (int i = 1; i <= N; i++) for (int j = 1; j <= P; j++) scanf("%lld", &a[i][j]); for (int i = 1; i <= P; i++) for (int j = 1; j <= M; j++) scanf("%lld", &b[i][j]); static long long c[Max + 1][Max + 1]; for (int i = 1; i <= N; i++) for (int k = 1; k <= P; k++) for (int j = 1; j <= M; j++) (c[i][j] += a[i][k] * b[k][j]) %= Mod; for (int i = 1; i <= N; i++) for (int j = 1; j <= M; j++) printf("%lld%c", (c[i][j] % Mod + Mod) % Mod, " \n"[j == M]); return 0; }
myj 吊打我Orz,xxy 捆起来打我Orz,myl 文化课上天Orz, lrh 姿势水平敲高Orz, hkd 特别胖Orz%%%,cys 智商感人Orz,syl zz专业Orz,我没有学上, 我们未来一片光明