結果

問題 No.2444 一次変換と体積
ユーザー KudeKude
提出日時 2023-08-25 21:47:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 71,616 KB
最終ジャッジ日時 2023-08-25 21:47:24
合計ジャッジ時間 2,944 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,156 KB
testcase_01 AC 72 ms
71,244 KB
testcase_02 AC 73 ms
71,240 KB
testcase_03 AC 72 ms
71,108 KB
testcase_04 AC 72 ms
71,512 KB
testcase_05 AC 72 ms
71,144 KB
testcase_06 AC 71 ms
71,228 KB
testcase_07 AC 71 ms
71,304 KB
testcase_08 AC 72 ms
71,436 KB
testcase_09 AC 74 ms
71,348 KB
testcase_10 AC 73 ms
71,460 KB
testcase_11 AC 72 ms
71,328 KB
testcase_12 WA -
testcase_13 AC 71 ms
71,104 KB
testcase_14 WA -
testcase_15 AC 70 ms
71,152 KB
testcase_16 AC 73 ms
71,276 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 72 ms
71,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, b = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(3)]

def mul(X, Y):
    res = [[0] * 3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            for k in range(3):
                res[i][k] += X[i][j] * Y[j][k]
    for i in range(3):
        for j in range(3):
            res[i][j] %= b
    return res

def det(a):
    res = 0
    for j in range(3):
        v = 1
        for i in range(3):
            v *= a[i][(j+i) % 3]
        res += v
    for j in range(3):
        v = 1
        for i in range(3):
            v *= a[i][(j-i) % 3]
        res -= v
    return res

an = [[int(i == j) for j in range(3)] for i in range(3)]
for k in range(n.bit_length())[::-1]:
    an = mul(an, an)
    if n >> k & 1:
        an = mul(an, a)

print(det(an) % b)
0