結果

問題 No.2679 MODice
ユーザー nikoro256nikoro256
提出日時 2024-03-20 22:00:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 53,588 KB
最終ジャッジ日時 2024-03-20 22:00:43
合計ジャッジ時間 1,569 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

'''
行列累乗ライブラリ
使用上の注意→ベクトルを入れる場合も二次元配列にする。
'''
def mat_mul(a, b, m) :
    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]
                c[i][j] %= m
    return c


def mat_pow(x, n, m):
    y = [[0] * len(x) for _ in range(len(x))]

    for i in range(len(x)):
        y[i][i] = 1

    while n > 0:
        if n & 1:
            y = mat_mul(x, y, m)
        x = mat_mul(x, x, m)
        n >>= 1

    return y

N,K=map(int,input().split())
print("166374059")
0