AO. 【模板】高斯消元法

    Type: RemoteJudge 1000ms 500MiB

【模板】高斯消元法

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目背景

如果想要更好地测试高斯消元算法模板请在通过此题后尝试通过 SDOI2006 线性方程组 这一题。

题目描述

给定一个线性方程组,对其求解。

$$\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} $$

输入格式

第一行,一个正整数 nn

第二至 n+1n+1 行,每行 n+1n+1 个整数,为 a1,a2,,an a_1, a_2, \dots ,a_nbb,代表一组方程。

输出格式

nn 行,每行一个数,第 ii 行为 xix_i(四舍五入保留 22 位小数)。

如果不存在唯一解或无解,在第一行输出 No Solution.

3
1 3 4 5
1 4 7 3
9 3 2 2
-0.97
5.18
-2.39

提示

本题 special judge 用于处理可能由于浮点数问题输出 -0.00 的情况。若某个 xix_i 的解四舍五入后是 0.00,那么你的程序输出 -0.00 和输出 0.00 都是正确的。

数据范围:$1 \leq n \leq 100, \left | a_i \right| \leq {10}^4 , \left |b \right| \leq {10}^4 $。保证数据若有解则所有解均满足 xi103|x_i|\le 10^3,且 xi±106x_i\pm 10^{-6}xix_i 四舍五入后的结果相同(即不会因为较小的精度误差导致四舍五入后的结果不同)。

【蒙青创】A班CSP备战模板

Not Claimed
Status
Done
Problem
68
Open Since
2025-10-24 0:00
Deadline
2025-10-31 23:59
Extension
24 hour(s)