给定一个 $n$ 阶行列式,请求出它的值。
第一行输入行列式的阶数 $n(1\leq n\leq 10)$。
接下来为 $n$ 行,每行 $n$ 个整数,用空格分开,表示行列式$x_{ij}(-100\leq x_{ij}\leq 100)$。
输出行列式的值,测试数据保证计算过程和结果中产生的值均不会超过 int
的范围。
提示:
以样例作为例子:
$$ \begin{aligned} \left( \begin{matrix} 2 & 3 & 0\\ -1 & 4 & 2\\ 1 & -2 & 3 \end{matrix} \right) &= 2\cdot \left( \begin{matrix} 4 & 2\\ -2 & 3 \end{matrix} \right) + (-1)\cdot 3\cdot \left( \begin{matrix} -1 & 2\\ 1 & 3 \end{matrix} \right) +0\cdot \left( \begin{matrix} -1 & 4\\ 1 & -2 \end{matrix} \right)\\ &=2\cdot 16 + (-3)\cdot (-5)=47 \end{aligned} $$
也即使用公式:
$$ \det(A)=\sum_{j_1j_2\dots j_n}(-1)^{\tau(j_1j_2\dots j_n)}\prod_{i=1}^n a_{ij_i} $$
3
2 3 0
-1 4 2
1 -2 3
47