Skip to content

Commit 50ad766

Browse files
committed
feat: Add matrix product test implementation for NMatrix using modint
1 parent 3faf036 commit 50ad766

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

test/matrix_product.test.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#define PROBLEM "https://judge.yosupo.jp/problem/matrix_product"
2+
3+
#include "../weilycoder/matrix.hpp"
4+
#include "../weilycoder/number_theory/modint.hpp"
5+
#include <cstdint>
6+
#include <iostream>
7+
using namespace std;
8+
using namespace weilycoder;
9+
10+
int main() {
11+
cin.tie(nullptr)->sync_with_stdio(false);
12+
cin.exceptions(cin.failbit | cin.badbit);
13+
size_t N, M, K;
14+
cin >> N >> M >> K;
15+
NMatrix<modint<998244353>> A(N, M), B(M, K);
16+
for (size_t i = 0; i < N; ++i)
17+
for (size_t j = 0; j < M; ++j)
18+
cin >> A(i, j);
19+
for (size_t i = 0; i < M; ++i)
20+
for (size_t j = 0; j < K; ++j)
21+
cin >> B(i, j);
22+
auto C = A * B;
23+
for (size_t i = 0; i < N; ++i)
24+
for (size_t j = 0; j < K; ++j)
25+
cout << C(i, j) << " \n"[j + 1 == K];
26+
return 0;
27+
}

0 commit comments

Comments
 (0)