P2455 [SDOI2006] System of Linear Equations
Description
Given an $n$-variable linear system of equations:
$$ \begin{cases} a_{1, 1} x_1 + a_{1, 2} x_2 + \cdots + a_{1, n} x_n = b_1 \\ a_{2, 1} x_1 + a_{2, 2} x_2 + \cdots + a_{2, n} x_n = b_2 \\ \cdots \\ a_{n,1} x_1 + a_{n, 2} x_2 + \cdots + a_{n, n} x_n = b_n \end{cases}$$
Based on the input, write a program to output the status of the solution set.
Input Format
The first line contains the number of unknowns $n$.
Then $n$ lines follow, each containing $n + 1$ integers, representing the coefficients of each equation and the value on the right-hand side.
Output Format
If there is a unique solution, output the solution. Your result is considered correct if and only if, for every $x_i$, the absolute error or the relative error compared to the standard answer does not exceed $0.01$.
If the system has no solution, output $-1$;
if it has infinitely many real solutions, output $0$.
Explanation/Hint
Constraints
For $100\%$ of the testdata, $1 \le n \le 50$. For all $1 \le i, j \le n$, $\left| a_{i, j} \right| \le 100$, $\left| b_i \right| \le 300$.
Translated by ChatGPT 5