結果

問題 No.2530 Yellow Cards
ユーザー titiatitia
提出日時 2023-11-06 01:59:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 62,300 KB
最終ジャッジ日時 2023-11-06 01:59:49
合計ジャッジ時間 5,045 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,516 KB
testcase_01 AC 37 ms
53,516 KB
testcase_02 AC 125 ms
62,284 KB
testcase_03 AC 61 ms
62,280 KB
testcase_04 AC 37 ms
53,516 KB
testcase_05 AC 124 ms
62,284 KB
testcase_06 AC 42 ms
59,612 KB
testcase_07 AC 294 ms
62,280 KB
testcase_08 AC 295 ms
62,280 KB
testcase_09 AC 294 ms
62,280 KB
testcase_10 AC 294 ms
62,280 KB
testcase_11 AC 298 ms
62,280 KB
testcase_12 AC 296 ms
62,280 KB
testcase_13 AC 296 ms
62,280 KB
testcase_14 AC 257 ms
62,280 KB
testcase_15 AC 201 ms
62,280 KB
testcase_16 AC 169 ms
62,280 KB
testcase_17 AC 260 ms
62,280 KB
testcase_18 AC 104 ms
62,280 KB
testcase_19 AC 61 ms
62,280 KB
testcase_20 AC 118 ms
62,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,K=map(int,input().split())
mod=998244353

DP=[0]*(N+K)
DP[0]=1

INV=pow(N,-1,mod)

for i in range(K):
    for j in range(N+K-2,-1,-1):
        if DP[j]==0:
            continue
        # 今まででたカードがi枚
        # yellow 二枚がj人
        # yellow一枚は
        one=i-j*2

        # one/Nで一人増え、それ以外では増えない
        DP[j+1]+=DP[j]*one%mod*INV%mod
        DP[j]=DP[j]*(1-one*INV%mod)%mod
        DP[j]%=mod
        DP[j+1]%=mod
        

ANS=0
for i in range(N+K-1):
    ANS+=DP[i]*(i+N)
    ANS%=mod

print(ANS%mod)
        
        
0