#P3389. P3389 【模板】高斯消元法
P3389 【模板】高斯消元法
题目描述
给定 (n) 元线性方程组 (A\mathbf{x}=\mathbf{b}),其中
[ A=\begin{pmatrix}a_{11}&\cdots&a_{1n}\ \vdots&\ddots&\vdots\ a_{n1}&\cdots&a_{nn}\end{pmatrix},\qquad \mathbf{b}=\begin{pmatrix}b_1\\vdots\ b_n\end{pmatrix} ]
所有元素都对质数 (998244353) 取模。保证方程组在模 (998244353) 意义下有唯一解,请输出这唯一解 (x_1,\dots,x_n)(每个都在 ([0,998244353)) 内)。
输入格式
第一行一个整数 (n)。 接下来 (n) 行,每行 (n+1) 个整数,前 (n) 个是矩阵 (A) 该行的元素,最后一个是对应的 (b_i)。 保证 (1\le n\le 1000),所有整数在 ([0,998244352]) 内,且 (A) 在模 (998244353) 下可逆。
输出格式
一行 (n) 个整数,依次为 (x_1,\dots,x_n)。
样例输入
2
308953193 824847613 402171523
825136158 755904516 449077366
样例输出
381541172 196651725