結果
問題 | No.2528 pop_(backfront or not) |
ユーザー |
![]() |
提出日時 | 2023-11-03 22:32:26 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 943 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 499,644 KB |
最終ジャッジ日時 | 2024-09-25 20:57:10 |
合計ジャッジ時間 | 7,282 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 TLE * 1 -- * 8 |
ソースコード
import sysinput = sys.stdin.readlinesys.setrecursionlimit(10**7)mod=998244353FACT=[1]for i in range(1,2*10**5+1):FACT.append(FACT[-1]*i%mod)FACT_INV=[pow(FACT[-1],mod-2,mod)]for i in range(2*10**5,0,-1):FACT_INV.append(FACT_INV[-1]*i%mod)FACT_INV.reverse()def Combi(a,b):if 0<=b<=a:return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%modelse:return 0N=int(input())from functools import lru_cache@lru_cache(maxsize=None)def calc(x,y):if y==1 or y==x:return 0if x==3:if y==2:return 1else:return 0ANS=0# 左から二つANS+=Combi(y-1-1,2)*calc(x-2,y-2)# 左右一つずつANS+=Combi(y-1-1,1)*Combi(x-y-1,1)*calc(x-2,y-1)# 端二つANS+=calc(x-2,y-1)# 右から二つANS+=Combi(x-y-1,2)*calc(x-2,y)return ANS%modfor i in range(1,N*2+2):print(calc(N*2+1,i))