結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー H3PO4H3PO4
提出日時 2022-08-31 09:22:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 548 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 55,744 KB
最終ジャッジ日時 2024-04-25 14:15:20
合計ジャッジ時間 43,622 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 535 ms
44,080 KB
testcase_01 AC 539 ms
44,068 KB
testcase_02 AC 544 ms
44,212 KB
testcase_03 AC 538 ms
44,312 KB
testcase_04 AC 543 ms
44,072 KB
testcase_05 AC 1,331 ms
45,604 KB
testcase_06 AC 1,132 ms
45,096 KB
testcase_07 AC 1,563 ms
46,120 KB
testcase_08 AC 603 ms
44,072 KB
testcase_09 AC 596 ms
44,196 KB
testcase_10 AC 539 ms
44,076 KB
testcase_11 TLE -
testcase_12 AC 543 ms
44,076 KB
testcase_13 AC 540 ms
44,204 KB
testcase_14 AC 561 ms
44,460 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

MOD = 10 ** 9 + 7


def pow_matrix_mod(x, n, mod=MOD):
    # x = x.astype(np.object)
    if not n:
        return np.eye(len(x), dtype=object)
    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


N, K, L = map(int, input().split())

matr = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(L):
        matr[i][(i + 1 + j) % N] = 1

res = pow_matrix_mod(np.array(matr, dtype=object), K)[0]
print(*res, sep="\n")
0