結果
| 問題 |
No.3224 2×2行列入門
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2025-08-12 14:20:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 897 bytes |
| コンパイル時間 | 3,189 ms |
| コンパイル使用メモリ | 275,728 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-12 14:20:47 |
| 合計ジャッジ時間 | 4,253 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; }
bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; }
using V = array<ll, 2>;
using Mat = array<V, 2>;
Mat mul(Mat a, Mat b) {
Mat c = Mat{V{0, 0}, V{0, 0}};
for (int i = 0; i < 2; i++) {
for (int k = 0; k < 2; k++) {
for (int j = 0; j < 2; j++) {
c[i][j] += a[i][k] * b[k][j];
}
}
}
return c;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
Mat A, B;
for (int s : {0, 1}) {
for (int t : {0, 1}) cin >> A[s][t];
}
for (int s : {0, 1}) {
for (int t : {0, 1}) cin >> B[s][t];
}
auto C = mul(A, B);
C = mul(C, C);
for (int s : {0, 1}) {
for (int t : {0, 1}) cout << C[s][t] << " \n"[t];
}
}
nonon