結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー shotoyooshotoyoo
提出日時 2021-05-28 21:22:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 62,336 KB
最終ジャッジ日時 2024-04-24 23:36:48
合計ジャッジ時間 2,828 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 42 ms
52,096 KB
testcase_02 AC 53 ms
59,648 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 43 ms
52,352 KB
testcase_05 AC 56 ms
61,184 KB
testcase_06 AC 57 ms
61,312 KB
testcase_07 AC 58 ms
61,696 KB
testcase_08 AC 54 ms
61,056 KB
testcase_09 AC 54 ms
60,928 KB
testcase_10 AC 50 ms
59,520 KB
testcase_11 AC 60 ms
61,696 KB
testcase_12 AC 42 ms
52,352 KB
testcase_13 AC 44 ms
52,224 KB
testcase_14 AC 51 ms
60,160 KB
testcase_15 AC 59 ms
61,568 KB
testcase_16 AC 60 ms
61,696 KB
testcase_17 AC 60 ms
61,952 KB
testcase_18 AC 61 ms
61,696 KB
testcase_19 AC 60 ms
61,568 KB
testcase_20 AC 60 ms
61,696 KB
testcase_21 AC 61 ms
61,568 KB
testcase_22 AC 59 ms
62,080 KB
testcase_23 AC 59 ms
61,824 KB
testcase_24 AC 60 ms
62,336 KB
testcase_25 AC 60 ms
61,696 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