Matrix Inverse
InterviewTime limit2sMemory limit1024 MB
For each 2x2 integer matrix, print its inverse over two lines with a case number, guaranteed to have integer entries.
- Level
Easy2 of 10
- Topics
- Math, Matrix, Implementation
- Solved
- No attempts yet
Problem
For a square matrix , its inverse is defined as the matrix satisfying the equality
where and are matrices, and is the identity matrix with ones along the diagonal and zeros everywhere else.
For this problem, you must write a program that finds the inverse of a matrix.
Input
Each test case is given in two lines. Each line contains two 32-bit signed integers, and the integers , , , given in that order are the entries of the matrix to invert.
A blank line follows each test case.
Output
For each case, print the case number, then print the inverse of the given matrix over two lines. Every test case is guaranteed to have an inverse (that is, no matrix is singular), and the entries of that inverse are integers. Follow the format of the sample output.