#C8223. Matrix Multiplication
Matrix Multiplication
Matrix Multiplication
In this problem, you are given two matrices ( A ) and ( B ). Matrix ( A ) has dimensions ( m \times n ) and matrix ( B ) has dimensions ( n \times p ). Your task is to compute the product ( C = A \times B ), where ( C ) is an ( m \times p ) matrix, and its element ( C[i][j] ) is given by: [ C[i][j] = \sum_{k=1}^{n} A[i][k] \times B[k][j] ]
Input Format: The input is read from standard input. The first line contains two integers ( m ) and ( n ), the dimensions of matrix ( A ). The next ( m ) lines each contain ( n ) integers representing the rows of matrix ( A ). The following line contains two integers ( n ) and ( p ), the dimensions of matrix ( B ). The next ( n ) lines each contain ( p ) integers representing the rows of matrix ( B }.
Output Format: Print the resulting matrix ( C ) to standard output. Each of the ( m ) lines should contain ( p ) space-separated integers.
inputFormat
The first line contains two integers ( m ) and ( n ): the number of rows and columns of matrix ( A ). Each of the next ( m ) lines contains ( n ) integers, representing the elements of matrix ( A ). The following line contains two integers ( n ) and ( p ): the number of rows and columns of matrix ( B ). Each of the next ( n ) lines contains ( p ) integers, representing the elements of matrix ( B ).
outputFormat
Print the resulting matrix ( C ) after multiplication. Output ( m ) lines, each containing ( p ) space-separated integers. There should be no extra spaces at the end of each line.## sample
2 3
1 2 3
4 5 6
3 2
7 8
9 10
11 12
58 64
139 154
</p>