結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー 👑 rin204rin204
提出日時 2022-04-15 17:33:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 77,536 KB
最終ジャッジ日時 2023-08-26 06:24:09
合計ジャッジ時間 5,774 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,160 KB
testcase_01 AC 69 ms
76,100 KB
testcase_02 AC 69 ms
76,236 KB
testcase_03 AC 61 ms
71,388 KB
testcase_04 AC 66 ms
71,320 KB
testcase_05 AC 151 ms
76,848 KB
testcase_06 AC 124 ms
76,728 KB
testcase_07 AC 155 ms
77,312 KB
testcase_08 AC 80 ms
76,376 KB
testcase_09 AC 76 ms
76,416 KB
testcase_10 AC 66 ms
76,424 KB
testcase_11 AC 217 ms
77,400 KB
testcase_12 AC 65 ms
71,324 KB
testcase_13 AC 73 ms
76,240 KB
testcase_14 AC 73 ms
76,352 KB
testcase_15 AC 224 ms
77,428 KB
testcase_16 AC 263 ms
77,412 KB
testcase_17 AC 263 ms
77,232 KB
testcase_18 AC 243 ms
77,404 KB
testcase_19 AC 253 ms
77,300 KB
testcase_20 AC 251 ms
77,528 KB
testcase_21 AC 261 ms
77,536 KB
testcase_22 AC 281 ms
77,432 KB
testcase_23 AC 215 ms
77,468 KB
testcase_24 AC 273 ms
77,424 KB
testcase_25 AC 273 ms
77,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

def matpow(A, B, w):
    l = len(A)
    while w:
        if w & 1:
            C = [0] * l
            for i in range(l):
                for j in range(l):
                    C[i] += A[i][j] * B[j]
                    C[i] %= MOD
            B = C
        C = [[0] * l for _ in range(l)]
        for i in range(l):
            for j in range(l):
                for k in range(l):
                    C[i][j] += A[i][k] * A[k][j]
                    C[i][j] %= MOD
        A = C
        w >>= 1
    return B

n, k, l = map(int, input().split())
B = [0] * n
B[0] = 1
A = [[0] * n for _ in range(n)]
for i in range(n):
    for j in range(1, l + 1):
        A[(i + j) % n][i] = 1

B = matpow(A, B, k)
print(*B, sep="\n")
0