結果

問題 No.1050 Zero (Maximum)
ユーザー H3PO4H3PO4
提出日時 2020-05-08 22:49:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 30,168 KB
最終ジャッジ日時 2023-09-17 03:18:04
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import numpy as np

M, K = map(int, input().split())

MOD = 10 ** 9 + 7
A = [[0] * M for _ in range(M)]
for i in range(M):
    for j in range(M):
        A[i][(i + j) % M] += 1
        A[i][(i * j) % M] += 1
A = np.array(A, dtype=np.int64)


def pow_matrix_mod(x, n):
    if n == 0:
        return np.eye(M, dtype=np.int64)
    if n % 2 == 0:
        return pow_matrix_mod(x @ x % MOD, n // 2) % MOD
    else:
        return x @ pow_matrix_mod(x @ x % MOD, (n - 1) // 2) % MOD


print(pow_matrix_mod(A, K)[0][0])
0