結果
| 問題 |
No.2441 行列累乗
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-25 21:35:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 881 bytes |
| コンパイル時間 | 1,800 ms |
| コンパイル使用メモリ | 170,572 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 08:02:38 |
| 合計ジャッジ時間 | 2,639 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define debug 1
using ll = long long;
using ld = long double;
const int mod = 998244353;
const double pi = atan2(0, -1);
#include <time.h>
#include <chrono>
int main() {
vector<vector<int>> input(2, vector<int>(2));
rep(i, 2) {
rep(j, 2) {
cin >> input[i][j];
}
}
vector<vector<int>> ans(2, vector<int>(2));
ans[0][0] = 1;
ans[0][1] = 0;
ans[1][0] = 0;
ans[1][1] = 1;
rep(i, 3) {
int a = ans[0][0];
int b = ans[0][1];
int c = ans[1][0];
int d = ans[1][1];
ans[0][0] = a * input[0][0] + b * input[1][0];
ans[0][1] = a * input[0][1] + b * input[1][1];
ans[1][0] = c * input[0][0] + d * input[1][0];
ans[1][1] = c * input[0][1] + d * input[1][1];
}
cout << ans[0][0] << " " << ans[0][1] << endl << ans[1][0] << " " << ans[1][1] << endl;
}