LU decomposition
Work over the finite field
You are given an \(n\times n\) matrix \(A\). Find matrices \(L\) and \(U\)
such that
The decomposition must use unit lower-triangular \(L\): all entries above its
diagonal are zero and \(L_{i,i}=1\). Matrix \(U\) must be upper triangular,
so all entries below its diagonal are zero.
The test matrices are guaranteed to admit such a decomposition without row
permutations. Any valid pair \((L,U)\) is accepted.
Input
The first line contains \(n\). The next \(n\) lines contain \(A\), with \(n\)
entries per line.
Output
Print the \(n\) rows of \(L\), followed immediately by the \(n\) rows of
\(U\). Each row contains \(n\) integers.
All arithmetic, including the matrix product \(LU\), is modulo \(p\). Any
integer representative of an entry is accepted.
Constraints
- \(1\le n\le 100\)
- Every matrix entry is an integer in \([0,p)\)