#453easyMatrix Operations
2x2 Matrix Multiplication
Time Limit: 2sMemory: 256MB
Problem
Given two matrices and , compute their product .
For 2x2 matrices, this expands to four entries, each being a dot product of a row of with a column of .
Input Format
Eight space-separated values: a11 a12 a21 a22 b11 b12 b21 b22
(Matrix in row-major order, then matrix in row-major order.)
Output Format
Four space-separated values: c11 c12 c21 c22, each to 4 decimal places.
Examples
Example 1
Input(Eight space-separated values: a11 a12 a21 a22 b11 b12 b21 b22)
1 2 3 4 5 6 7 8
Output
19.0000 22.0000 43.0000 50.0000
A=[[1,2],[3,4]] * B=[[5,6],[7,8]] = [[19,22],[43,50]].
Example 2
Input(Eight space-separated values: a11 a12 a21 a22 b11 b12 b21 b22)
1 0 0 1 3 4 5 6
Output
3.0000 4.0000 5.0000 6.0000
Identity times B equals B.
Constraints
- •-1000 ≤ matrix entries ≤ 1000
- •Output to 4 decimal places
Loading interactive editor…