## System Solver

View as PDF

Points: 20 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type

A system of linear equations is a collection of linear equations involving the same set of variables. A general system of linear equations with unknowns can be written as:

Here, are the unknowns, are the coefficients of the system, and are the constant terms. (Source: Wikipedia)

Write a program that solves a system of linear equations with a maximum of equations and variables.

#### Input Specification

Line of the input contains integers and , indicating the number of variables to solve for and the number of equations in the system.
The next lines will each contain integers, where the first integers are the coefficients of the equation and the last integer is the constant term.
Every number in the input is guaranteed to fit in a -bit signed integer.

#### Output Specification

If the system can be solved, output lines, the values of the unknowns , accurate within .
If there are no solutions to the system, or if there are infinite solutions to the system, output NO UNIQUE SOLUTION.

#### Sample Input 1

2 2
1 3 4
2 3 6

#### Sample Output 1

2
0.66667

#### Explanation

This asks for the solution(s) for in the system:

Solving for in the first equation gives . Substituting this into the -nd equation and simplifying yields .
Solving for yields . Substituting back into the first equation and solving for yields .
Therefore the solution set is the single point .

#### Sample Input 2

2 3
6 2 2
12 4 8
6 2 4

#### Sample Output 2

NO UNIQUE SOLUTION

#### Explanation

All of the lines are parallel. Therefore, the system of equations cannot be solved.