結果

問題 No.2679 MODice
ユーザー 👑 H20H20
提出日時 2024-03-20 21:15:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 698 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-03-20 21:15:46
合計ジャッジ時間 1,676 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,112 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 30 ms
10,112 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 30 ms
10,112 KB
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int, input().split())
mod = 998244353
def matrix_multiply(A, B):
    """2つの行列AとBの乗算を行う"""
    result = [[0 for _ in range(len(B[0]))] for _ in range(len(A))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(B)):
                result[i][j] = (A[i][k] * B[k][j])%mod
    return result



divsix = pow(6,mod-2,mod)



transition_matrix = [[divsix for _ in range(6)] for _ in range(6)]
ANS = [[divsix for _ in range(6)] for _ in range(6)]
while K:
    if K & 1:
        ANS = matrix_multiply(ANS, transition_matrix)
    transition_matrix = matrix_multiply(transition_matrix, transition_matrix)
    K //= 2
print(ANS[0][K])
0