4369 - 대수: 행렬 곱1

Time Limit: 1s Memory Limit: 128MB

Submissions: 870 Solved: 501
Description

행렬a와 행렬b를 곱하기 위해서는 행렬a의 열의 개수와 행렬b의 행의 개수가 일치 해야하고, 두 행렬의 각각의 원소는 동일한 자료형을 가져야 한다. 행렬c를 행렬a와 행렬b를 곱해서 만든 행렬이라고 하자. 행렬a의 열의 개수를 n이라면 행렬c의 ij원소는 ai1 * b1j + ai2 * b2j + ... + ain * bnj 이다.

To multiply matrix a by matrix b, the number of columns in a must be the same as the number of rows in b, and the two matrices must have elements of the same or compatible types. Let c be the result of the multiplication. Assume the column size of matrix a is n. Each element cij is ai1 * b1j + ai2 * b2j + ... + ain * bnj.

여러분은 두개의 3*3 행렬을 입력으로 받아, 두 행렬을 곱한 새로운 행렬을 구해야 한다.  

Write a test program that prompts the user to enter two 3 * 3 matrices and displays their product. 

 

Input

* Line 1 ~ 3 : 첫번째 행렬의 행 (공백으로 구분된 3개의 원소)

* Line 4 ~ 6 : 두번째 행렬의 행 (공백으로 구분된 3개의 원소)

- 모든 행렬의 원소는 정수이며 범위는 -1,000~1,000

 

Output

* Line 1 ~ 3 : 곱해진 행렬의 행 (행의 원소를 공백으로 구분해 출력)

 

Sample Input
1 2 3
3 2 1
2 1 3
4 5 6
6 5 4
4 6 5
Sample Output
28 33 29
28 31 31
26 33 31
Source

JAVA2015 PE8.6