#Q221. 「一本通 6.5 例 1」矩阵 A×B
「一本通 6.5 例 1」矩阵 A×B
Description
Matrix has dimensions , and matrix has dimensions . Your task is to compute the product .
Definition of matrix multiplication: The product of an matrix and an matrix results in an matrix. Let be an element of matrix , and be an element of matrix . Then, the elements of the resulting matrix are given by:
Refer to the sample for a concrete example.
Input Format
The first line contains two integers and ;
Next, lines follow, each containing integers, describing matrix ;
The following line contains an integer ;
Next, lines follow, each containing integers, describing matrix .
Output Format
Output the matrix , which is the product of matrix and matrix .
Sample 1
$$\begin{bmatrix} 14=1\times 1+2\times 2+3\times 3&14=1\times 1+2\times 2+3\times 3\\ 10=3\times 1+2\times 2+1\times 3&10=3\times 1+2\times 2+1\times 3 \end{bmatrix} $$2 3
1 2 3
3 2 1
2
1 1
2 2
3 3
14 14
10 10
Data Range and Hint
For all data, , and .