結果

問題 No.2444 一次変換と体積
ユーザー Nikkuniku029Nikkuniku029
提出日時 2023-08-25 23:22:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 953 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 29,808 KB
最終ジャッジ日時 2023-08-25 23:22:17
合計ジャッジ時間 4,106 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
29,564 KB
testcase_01 AC 130 ms
29,536 KB
testcase_02 AC 130 ms
29,636 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 130 ms
29,504 KB
testcase_06 AC 129 ms
29,388 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 131 ms
29,520 KB
testcase_10 AC 137 ms
29,500 KB
testcase_11 AC 130 ms
29,520 KB
testcase_12 AC 157 ms
29,572 KB
testcase_13 AC 129 ms
29,588 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 131 ms
29,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np


def modinv(a: int, m: int) -> int:
    '''
    モジュラ逆元
    ax mod m =1の解x=a^(-1)を返す

    Parameters
    ----------
    a:int
    m:int
    '''
    x, y, u, v = 1, 0, 0, 1
    M = m
    while m > 0:
        k = a//m
        x -= k*u
        y -= k*v
        x, u = u, x
        y, v = v, y
        a, m = m, a % m
    assert a == 1, "a and m aren't relatively prime numbers"
    if x < 0:
        x += M
    return x


def mat_mul(a, b):
    """
    a: 行列(2次元配列)I*J
    b: 行列(2次元配列)J*K
    """
    I, J, K = len(a), len(b[0]), len(b)
    c = [[0] * J for _ in range(I)]
    for i in range(I):
        for j in range(J):
            for k in range(K):
                c[i][j] += a[i][k] * b[k][j]
    return c


N, B = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(3)]
mat = np.matrix(A)
det = int(np.linalg.det(mat))
detn = pow(abs(det), N, B)
print(detn)
0