結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー shotoyooshotoyoo
提出日時 2021-05-28 21:22:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 76,524 KB
最終ジャッジ日時 2023-08-07 05:27:19
合計ジャッジ時間 3,674 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,440 KB
testcase_01 AC 82 ms
71,392 KB
testcase_02 AC 83 ms
76,296 KB
testcase_03 AC 74 ms
71,280 KB
testcase_04 AC 73 ms
71,436 KB
testcase_05 AC 83 ms
76,436 KB
testcase_06 AC 83 ms
76,356 KB
testcase_07 AC 86 ms
76,268 KB
testcase_08 AC 83 ms
76,236 KB
testcase_09 AC 83 ms
76,108 KB
testcase_10 AC 80 ms
75,732 KB
testcase_11 AC 89 ms
76,468 KB
testcase_12 AC 75 ms
71,448 KB
testcase_13 AC 77 ms
71,384 KB
testcase_14 AC 82 ms
76,228 KB
testcase_15 AC 88 ms
76,180 KB
testcase_16 AC 88 ms
76,308 KB
testcase_17 AC 86 ms
76,456 KB
testcase_18 AC 87 ms
76,468 KB
testcase_19 AC 88 ms
76,464 KB
testcase_20 AC 88 ms
76,524 KB
testcase_21 AC 89 ms
76,376 KB
testcase_22 AC 86 ms
76,456 KB
testcase_23 AC 89 ms
76,480 KB
testcase_24 AC 88 ms
76,312 KB
testcase_25 AC 88 ms
76,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,k,l = list(map(int, input().split()))
M = 10**9+7
def pmul(a,b):
    n = len(a)
    m = len(b)
    c = [0]*(n+m-1)
    for i in range(n):
        for j in range(m):
            c[i+j] += a[i]*b[j]%M
            if c[i+j] > M:
                c[i+j] -= M
    return c
def pmulk(a,k):
    ans = [1]
    while k:
        if k&1:
            ans = pmul(ans, a)
            nans = [0]*n
            for i in range(len(ans)):
                nans[i%n] += ans[i]
                nans[i%n] %= M
            ans = nans
        k = k>>1
        a = pmul(a,a)
        na = [0]*n
        for i in range(len(a)):
            na[i%n] += a[i]
            na[i%n] %= M
        a = na
#     print(len(ans))
    return ans[:n]
if n==l:
    a = [1]*n
else:
    a = [0] + [1]*l + [0]*(n-l-1)
ans = pmulk(a, k)
write("\n".join(map(str, ans)))
0