#P3389. 【模板】高斯消元法
【模板】高斯消元法
Description
Given a system of linear equations, solve it.
$$\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}$$Input Format
The first line contains a positive integer .
Lines to each contain integers, which are and , representing one equation.
Output Format
Output lines, one number per line. The -th line is (rounded to decimal places).
If there is no solution or the solution is not unique, output No Solution on the first line.
3
1 3 4 5
1 4 7 3
9 3 2 2
-0.97
5.18
-2.39
Hint
This problem uses a special judge to handle cases where floating-point issues might produce -0.00. If some rounds to 0.00, then both -0.00 and 0.00 are accepted.
Constraints: $1 \leq n \leq 100, \left | a_i \right| \leq {10}^4 , \left |b \right| \leq {10}^4$. It is guaranteed that if there is a solution, then all solutions satisfy , and the rounded results of and are the same (i.e., small precision errors will not change the rounded result).
Translated by ChatGPT 5
京公网安备 11011102002149号