結果

問題 No.2444 一次変換と体積
コンテスト
ユーザー SSRS
提出日時 2023-08-25 21:38:40
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 769 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,342 ms
コンパイル使用メモリ 213,944 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-07-02 07:05:23
合計ジャッジ時間 2,225 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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 = (det % B + B) % B;
  cout << modpow(det, N, B) << endl;
}
0