09: matrix multiplication, 09: Matrix Multiplication
09: Matrix Multiplication
 View
 Submit
 Statistics
 Question

Total time limit:

1000 ms

Memory limit:

65536kB

Description

Calculate the multiplication of two matrices. N * mlevel matrix A multiplied by m * klevel matrix B. The obtained matrix C is n * klevel, and C [I] [j] = A [I] [0] * B [0] [j] + A [I] [1] * B [1] [j] + ...... + A [I] [M1] * B [s1] [j] (C [I] [j] indicates column j of row I in the C matrix ).

Input

The first act is n, m, k, indicating that the matrix is n rows of m columns, the B matrix is m rows of k columns, n, m, k are less than 100
Then, input two matrices, A and B. The A matrix has n rows and m columns, and the B Matrix has m rows and k columns. The absolute values of each element in the matrix are not greater than 1000.

Output

Output matrix C, n rows in total, k integers in each row, separated by a space.

Sample Input

3 2 31 11 11 11 1 11 1 1

Sample output

2 2 22 2 22 2 2
# Include <iostream> using namespace std; int a [1001] [1001]; int B [1001] [1001]; int c [1001] [1001]; int now = 1; // record the I value int tot; // record S1 int main () {int n, k, m; cin> n> m> k; for (int I = 1; I <= n; I ++) {for (int j = 1; j <= m; j ++) {cin> a [I] [j] ;}} for (int I = 1; I <= m; I ++) {for (int j = 1; j <= k; j ++) {cin> B [I] [j] ;}} for (int I = 1; I <= n; I ++) {for (int j = 1; j <= k; j ++) {while (now <= m) {c [I] [j] = a [I] [now] * B [now] [j] + c [I] [j]; now ++ ;} now = 1 ;}}for (int I = 1; I <= n; I ++) {for (int j = 1; j <= k; j ++) {cout <c [I] [j] <";}cout <endl;} return 0 ;}