← 返回 microsoft 的题目列表Matrix Multiplication
类型:online_judge
Implement matrix multiplication. Given two integer matrices A and B, where A is m x n and B is n x p, compute the product C = A * B and return the m x p matrix C.
Requirements:
If dimensions do not match (number of columns of A != number of rows of B), clearly define your behavior (e.g., return an empty result or raise an error).
I/O convention (for coding)
Input: m n p, followed by m rows of A, then n rows of B
Output: m rows, each with p integers for matrix C
Constraints
1 <= m, n, p <= 200
Elements are 32-bit signed integers
Example
Input:
2 3 2
1 2 3
4 5 6
7 8
9 10
11 12
Output:
58 64
139 154
Example
Input
2 3 2
1 2 3
4 5 6
7 8
9 10
11 12
Output
58 64
139 154