結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー nasubi24nasubi24
提出日時 2021-05-28 21:42:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 799 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 78,336 KB
最終ジャッジ日時 2024-04-24 23:53:31
合計ジャッジ時間 10,629 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
53,120 KB
testcase_01 AC 53 ms
59,904 KB
testcase_02 AC 54 ms
60,800 KB
testcase_03 AC 42 ms
52,352 KB
testcase_04 AC 51 ms
60,160 KB
testcase_05 AC 300 ms
70,144 KB
testcase_06 AC 244 ms
69,248 KB
testcase_07 AC 315 ms
70,912 KB
testcase_08 AC 75 ms
64,000 KB
testcase_09 AC 72 ms
63,360 KB
testcase_10 AC 54 ms
60,672 KB
testcase_11 AC 547 ms
73,856 KB
testcase_12 AC 41 ms
52,224 KB
testcase_13 AC 52 ms
60,416 KB
testcase_14 AC 60 ms
62,848 KB
testcase_15 AC 583 ms
74,240 KB
testcase_16 AC 679 ms
77,824 KB
testcase_17 AC 692 ms
77,824 KB
testcase_18 AC 632 ms
74,624 KB
testcase_19 AC 682 ms
77,952 KB
testcase_20 AC 706 ms
77,824 KB
testcase_21 AC 682 ms
77,952 KB
testcase_22 AC 752 ms
78,080 KB
testcase_23 AC 535 ms
73,472 KB
testcase_24 AC 799 ms
78,336 KB
testcase_25 AC 738 ms
77,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k,l=map(int,input().split())
dp=[[[0]*n for _ in range(22)] for z in range(n)]
for i in range(n):
    dp[i][0][i]=1
mod=10**9+7
for i in range(n):
    for j in range(1,l+1):
        dp[i][1][(j+i)%n]=1
for j in range(1,21):
    for i in range(n):
        for l in range(n):
            for m in range(n):
                dp[i][j+1][l]+=dp[i][j][m]*dp[m][j][l]
                dp[i][j+1][l]%=mod
s=bin(k)[2:]
ans=[[0]*n for _ in range(len(s)+1)]
ans[0][0]=1
for i in range(len(s)):
    if s[-1-i]=="1":
        for j in range(n):
            for k in range(n):
                ans[i+1][k%n]+=ans[i][j]*dp[j][i+1][k]
                ans[i+1][k%n]%=mod
    else:
        for j in range(n):
            ans[i+1][j]=ans[i][j]
for i in ans[-1]:
    print(i)
0