結果

問題 No.2528 pop_(backfront or not)
ユーザー miya145592miya145592
提出日時 2023-11-04 04:45:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 748 ms / 2,000 ms
コード長 1,257 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 200,808 KB
最終ジャッジ日時 2023-11-04 04:45:46
合計ジャッジ時間 6,112 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,600 KB
testcase_01 AC 36 ms
53,600 KB
testcase_02 AC 36 ms
53,600 KB
testcase_03 AC 37 ms
53,600 KB
testcase_04 AC 37 ms
53,600 KB
testcase_05 AC 54 ms
66,336 KB
testcase_06 AC 61 ms
68,424 KB
testcase_07 AC 96 ms
78,208 KB
testcase_08 AC 97 ms
79,000 KB
testcase_09 AC 134 ms
85,908 KB
testcase_10 AC 245 ms
107,108 KB
testcase_11 AC 265 ms
109,912 KB
testcase_12 AC 331 ms
124,384 KB
testcase_13 AC 357 ms
129,420 KB
testcase_14 AC 427 ms
141,952 KB
testcase_15 AC 606 ms
178,124 KB
testcase_16 AC 742 ms
200,664 KB
testcase_17 AC 729 ms
200,736 KB
testcase_18 AC 748 ms
200,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def nPr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod

def nCr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] % mod) * g2[n-r] % mod

import sys
input = sys.stdin.readline
MOD = 998244353
N = int(input())
M = 2*N+1

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
fact = [1, 1]
fact_inv = [1, 1]

for i in range( 2, M + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )
    fact.append( (fact[-1] * i) % MOD )
    fact_inv.append(fact_inv[-1] * inverse[-1] % MOD)

dp = [[0 for _ in range(M)] for _ in range(M)]
dp[0][0] = 1
for i in range(M):
    for j in range(M):
        if dp[i][j]==0:
            continue
        if i+2<M:
            dp[i+2][j] += dp[i][j] * nCr(i+1, 2, MOD) % MOD
            dp[i+2][j] %= MOD
        if j+2<M:
            dp[i][j+2] += dp[i][j] * nCr(j+1, 2, MOD) % MOD
            dp[i][j+2] %= MOD
        if i+1<M and j+1<M:
            dp[i+1][j+1] += dp[i][j] * (i*j+1) % MOD
            dp[i+1][j+1] %= MOD
#print(dp)
for k in range(M):
    print(dp[k][M-k-1])
0