#K51687. Matrix Multiplication
Matrix Multiplication
Matrix Multiplication
You are given two matrices A and B. Matrix A is of size (n \times m) and matrix B is of size (m \times p). Your task is to compute the product matrix (C) of size (n \times p) where each element (C_{i,j}) is given by:
[ C_{i,j} = \sum_{k=1}^{m} A_{i,k} \times B_{k,j} ]
Input is provided from standard input (stdin) and the result should be printed to standard output (stdout). Ensure that you handle matrices of various dimensions including non-square matrices, identity matrices, and matrices with zero values.
inputFormat
The first line contains three integers (n), (m), and (p), representing the number of rows of matrix A, number of columns of matrix A (and rows of matrix B), and number of columns of matrix B respectively. The next (n) lines each contain (m) integers representing the rows of matrix A. This is followed by (m) lines each containing (p) integers representing the rows of matrix B.
outputFormat
Output the resulting matrix (C) in (n) lines. Each line should contain (p) space-separated integers corresponding to the elements of that row of the matrix.## sample
2 3 2
1 2 3
4 5 6
7 8
9 10
11 12
58 64
139 154
</p>