結果

問題 No.2528 pop_(backfront or not)
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-12 02:53:46
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,327 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 205,268 KB
最終ジャッジ日時 2023-11-12 02:53:54
合計ジャッジ時間 6,915 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,740 KB
testcase_01 AC 47 ms
55,740 KB
testcase_02 AC 46 ms
55,740 KB
testcase_03 AC 46 ms
55,740 KB
testcase_04 AC 47 ms
55,740 KB
testcase_05 AC 76 ms
76,220 KB
testcase_06 AC 85 ms
76,756 KB
testcase_07 AC 107 ms
78,372 KB
testcase_08 AC 118 ms
79,276 KB
testcase_09 AC 213 ms
88,276 KB
testcase_10 AC 519 ms
119,124 KB
testcase_11 AC 560 ms
124,756 KB
testcase_12 AC 754 ms
147,028 KB
testcase_13 AC 867 ms
156,756 KB
testcase_14 AC 1,047 ms
177,620 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline


N = int(input())

mod = 998244353
class combination():
    
    def __init__(self,N,p):
        
        
        self.fact = [1, 1]  # fact[n] = (n! mod p)
        self.factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
        self.inv = [0, 1]  # factinv 計算用
        self.p = p
        
        for i in range(2, N + 1):
            self.fact.append((self.fact[-1] * i) % p)
            self.inv.append((-self.inv[p % i] * (p // i)) % p)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % p)
        

    def cmb(self,n, r):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.p
M = 2*N+1
C = combination(M,mod)
mem = [[-1]*(M+1) for _ in range(M+1)]
mem[0][0] = 1
# mem[2][0] = 1
def f(x,y):
    x,y = max(x,y),min(x,y)
    if mem[x][y]!=-1:
        return mem[x][y]
    if y<0:
        return 0
    if y==0:
        mem[x][y] = C.cmb(x-1,2)*f(x-2,y)%mod
        return mem[x][y]
        
    mem[x][y] = (C.cmb(x-1,2)*f(x-2,y) + f(x-1,y-1)*((x-1)*(y-1)+1) + C.cmb(y-1,2)*f(x,y-2))%mod
    return mem[x][y]
        
for i in range(1,M+1):
    print(f(i-1,M-i))
0