結果

問題 No.2444 一次変換と体積
ユーザー SSRSSSRS
提出日時 2023-08-25 22:12:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 2,456 ms
コンパイル使用メモリ 203,064 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 22:12:11
合計ジャッジ時間 2,865 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long b, long long mod){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= mod;
    }
    a *= a;
    a %= mod;
    b /= 2;
  }
  return ans;
}
int main(){
  int N, B;
  cin >> N >> B;
  vector<vector<long long>> A(3, vector<long long>(3));
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> A[i][j];
    }
  }
  long long det = 0;
  det += A[0][0] * A[1][1] * A[2][2];
  det += A[0][1] * A[1][2] * A[2][0];
  det += A[0][2] * A[1][0] * A[2][1];
  det -= A[0][0] * A[1][2] * A[2][1];
  det -= A[0][1] * A[1][0] * A[2][2];
  det -= A[0][2] * A[1][1] * A[2][0];
  det = abs(det);
  det = (det % B + B) % B;
  cout << modpow(det, N, B) << endl;
}
0