Calculating the determinant of a matrix using the Gaussian method
C#
Hard
math
Task «Calculating the determinant of a matrix using the Gaussian method»
Given a square matrix of integers. It is necessary to compute its determinant using the Gaussian method (reduction to upper triangular form). The size of the matrix does not exceed 10x10. The matrix elements are integers from -1000 to 1000. The determinant may be fractional, so the answer is output as a floating-point number with two decimal places. It is guaranteed that the determinant exists.
Input Format
The first line contains an integer n (1 ≤ n ≤ 10) — the size of the matrix. Then follow n lines, each containing n integers separated by spaces — the elements of the matrix.
Output Format
Output a single number — the determinant of the matrix, rounded to two decimal places.
Examples
Example 1
INPUT
3
1 2 3
4 5 6
7 8 10
OUTPUT
-3.00
Example 2
INPUT
abracadabra
OUTPUT
F11F5F2F1LrF1LbF3F1LcF1LdF1LaF6LaF3LaF2Lr
Example 3
INPUT
2
5 7
2 3
OUTPUT
1.00
Example 4
INPUT
3 nil 5 nil 7
OUTPUT
9 nil 25 nil 49
Example 5
INPUT
a
OUTPUT
L1La
main.cs