Problems > Matrix Determinant mod p

Matrix Determinant mod p

Difficulty: 2100 6000 ms 128 MB

number-theory linear-algebra

Compute the determinant of an N×N integer matrix modulo 109+7.

Input: the first line has N; the next N lines give the matrix rows.

Output: the determinant mod 109+7 (in [0, p−1]).

Constraints:

  • 1 ≤ N ≤ 300
  • 0 ≤ entries < 109+7

Sample Tests

Input 1
2
1 2
3 4
Output 1
1000000005
Input 2
1
7
Output 2
7
Input 3
2
2 4
1 2
Output 3
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.