結果

問題 No.2441 行列累乗
ユーザー Nzt3Nzt3
提出日時 2023-08-25 21:29:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 198,136 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 21:30:03
合計ジャッジ時間 2,965 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  array<array<int,2>,2>M,ret;
  cin>>M[0][0]>>M[0][1]>>M[1][0]>>M[1][1];
  ret[0][1]=ret[1][0]=0;
  ret[0][0]=ret[1][1]=1;
  for(int i=0;i<3;i++){
    array<array<int,2>,2>n;
    n[0][0]=n[0][1]=n[1][0]=n[1][1]=0;
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        for(int l=0;l<2;l++){
          n[j][k]+=ret[j][l]*M[l][k];
        }
      }
    }
    ret=n;
  }
  cout<<ret[0][0]<<' '<<ret[0][1]<<'\n'<<ret[1][0]<<' '<<ret[1][1]<<'\n';
}
0