結果

問題 No.2528 pop_(backfront or not)
ユーザー KoiKoi
提出日時 2023-11-03 22:35:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 467 ms / 2,000 ms
コード長 763 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 77,980 KB
最終ジャッジ日時 2023-11-03 22:35:26
合計ジャッジ時間 4,778 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
59,732 KB
testcase_01 AC 42 ms
59,732 KB
testcase_02 AC 42 ms
59,732 KB
testcase_03 AC 43 ms
59,732 KB
testcase_04 AC 42 ms
59,732 KB
testcase_05 AC 54 ms
66,536 KB
testcase_06 AC 61 ms
70,668 KB
testcase_07 AC 71 ms
75,776 KB
testcase_08 AC 79 ms
75,956 KB
testcase_09 AC 110 ms
76,356 KB
testcase_10 AC 173 ms
76,516 KB
testcase_11 AC 179 ms
76,600 KB
testcase_12 AC 221 ms
76,712 KB
testcase_13 AC 237 ms
76,788 KB
testcase_14 AC 271 ms
76,956 KB
testcase_15 AC 376 ms
77,620 KB
testcase_16 AC 440 ms
77,916 KB
testcase_17 AC 467 ms
77,980 KB
testcase_18 AC 441 ms
77,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Mod=998244353
N=int(input())
dp=[0]*(2*N+1)
dp[0]=1
facts=[]
inv_facts=[]
t=1
for i in range(4100+1):
    facts.append(t)
    t=t*(i+1)%Mod
inv_facts.append(pow(facts[4100],-1,Mod))
for i in range(4100):
    inv_facts.append(inv_facts[-1]*(4100-i)%Mod)
inv_facts.reverse()
def Comb(n,k):
    if(n<k or n<0):
        return 0
    return facts[n]*inv_facts[k]*inv_facts[n-k]%Mod
for i in range(1,N+1):
    M=2*i+1
    new_dp=[0]*(2*N+1)
    for j in range(M//2+1):
        if(j==0):
            continue
        else:
            new_dp[j]=dp[j-1]+dp[j-2]*Comb(j-1,2)+dp[j-1]*(j-1)*(M-j-2)%Mod+dp[j]*Comb(M-j-2,2)
            new_dp[j]%=Mod
            new_dp[M-1-j]=new_dp[j]
    dp=[_ for _ in new_dp]
for i in range(2*N+1):
    print(dp[i])
        
            
0