#452easyMatrix Operations
Solve 2x2 Linear System
Time Limit: 2sMemory: 256MB
Problem
Given a matrix and a vector , solve the linear system using Cramer's rule (or direct matrix inversion).
The determinant is guaranteed to be nonzero.
Input Format
Six space-separated values: a11 a12 a21 a22 b1 b2
Output Format
Two space-separated values: x1 x2, each to 4 decimal places.
Examples
Example 1
Input(Six space-separated values: a11 a12 a21 a22 b1 b2)
2 1 1 3 5 7
Output
1.6000 1.8000
2x+y=5, x+3y=7. det=5, x1=(15-7)/5=1.6, x2=(14-5)/5=1.8.
Example 2
Input(Six space-separated values: a11 a12 a21 a22 b1 b2)
1 0 0 1 3 4
Output
3.0000 4.0000
Identity matrix: x1=3, x2=4.
Constraints
- •Determinant of A is nonzero (system has unique solution)
- •-1000 ≤ matrix entries ≤ 1000
- •Output to 4 decimal places
Loading interactive editor…