結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー gorugo30gorugo30
提出日時 2021-05-28 20:59:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 725 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,800 KB
最終ジャッジ日時 2024-04-24 23:16:08
合計ジャッジ時間 6,669 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,096 KB
testcase_01 AC 53 ms
59,904 KB
testcase_02 AC 55 ms
61,184 KB
testcase_03 AC 48 ms
52,224 KB
testcase_04 AC 46 ms
51,968 KB
testcase_05 WA -
testcase_06 AC 140 ms
71,808 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 54 ms
60,416 KB
testcase_11 WA -
testcase_12 AC 43 ms
52,224 KB
testcase_13 AC 54 ms
60,544 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 337 ms
76,288 KB
testcase_23 WA -
testcase_24 AC 339 ms
76,160 KB
testcase_25 AC 446 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
def matmul(A, B):
    ret = [[0] * len(B[0]) for i in range(len(A))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(A[0])):
                ret[i][j] = (ret[i][j] + A[i][k] * B[j][k]) % MOD
    return ret
def matpow(A, n):
    ret = [[0] * len(A) for i in range(len(A))]
    for i in range(len(A)):
        ret[i][i] = 1
    while n > 0:
        if n % 2:
            ret = matmul(ret, A)
        n //= 2
        A = matmul(A, A)
    return ret

N, K, L = map(int, input().split())
A = [[0] * N for i in range(N)]
for i in range(N):
    for j in range(i + 1, i + L + 1):
        A[i][j % N] = 1
A = matpow(A, K)

print(*[A[i][0] for i in range(N)], sep = "\n")
0