Skip to content

Commit b12196a

Browse files
committed
Add matrix tests
1 parent dac6b5b commit b12196a

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#define PROBLEM "https://judge.yosupo.jp/problem/matrix_det"
2+
#include "../../modint.hpp"
3+
#include "../matrix.hpp"
4+
#include <iostream>
5+
using namespace std;
6+
7+
int main() {
8+
cin.tie(nullptr);
9+
ios::sync_with_stdio(false);
10+
11+
int N;
12+
cin >> N;
13+
matrix<ModInt<998244353>> M(N, N);
14+
cin >> M;
15+
cout << M.gauss_jordan().determinant_of_upper_triangle() << '\n';
16+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#define PROBLEM "https://judge.yosupo.jp/problem/pow_of_matrix"
2+
#include "../../modint.hpp"
3+
#include "../matrix.hpp"
4+
#include <iostream>
5+
using namespace std;
6+
7+
int main() {
8+
cin.tie(nullptr);
9+
ios::sync_with_stdio(false);
10+
11+
int N;
12+
long long K;
13+
cin >> N >> K;
14+
matrix<ModInt<998244353>> M(N, N);
15+
cin >> M;
16+
M = M.pow(K);
17+
for (int i = 0; i < N; ++i) {
18+
cout << M[i][0];
19+
for (int j = 1; j < N; ++j) cout << ' ' << M[i][j];
20+
cout << '\n';
21+
}
22+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#define PROBLEM "https://judge.yosupo.jp/problem/matrix_rank"
2+
#include "../../modint.hpp"
3+
#include "../matrix.hpp"
4+
#include <iostream>
5+
using namespace std;
6+
7+
int main() {
8+
cin.tie(nullptr);
9+
ios::sync_with_stdio(false);
10+
11+
int N, M;
12+
cin >> N >> M;
13+
matrix<ModInt<998244353>> mat(N, M);
14+
cin >> mat;
15+
cout << mat.gauss_jordan().rank_of_gauss_jordan() << '\n';
16+
}

0 commit comments

Comments
 (0)