結果

問題 No.2679 MODice
ユーザー 👑 H20H20
提出日時 2024-03-20 21:20:27
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 742 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 65,928 KB
最終ジャッジ日時 2024-03-20 21:20:29
合計ジャッジ時間 1,743 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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] = (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 = [[0 for _ in range(6)] for _ in range(6)]
for i in range(N):
    ANS[i][i]=1

while N:
    if N & 1:
        ANS = matrix_multiply(ANS, transition_matrix)
    transition_matrix = matrix_multiply(transition_matrix, transition_matrix)
    N //= 2
print(ANS[0][K])
0