結果

問題 No.2105 Avoid MeX
ユーザー 👑 rin204
提出日時 2022-10-28 15:18:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-07-05 19:46:10
合計ジャッジ時間 2,909 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

c, x = map(int, input().split())

if x == 0:
    print(pow(c + 1, MOD - 2, MOD))
    exit()

dp = [0] * (x + 1)
dp[0] = 1
for i in range(c + 1, x + 1):
    ndp = [0] * (x + 1)
    inv = pow(i, MOD - 2, MOD)
    for j in range(x):
        ndp[j] += dp[j] * (j * inv % MOD)
        ndp[j] %= MOD
        ndp[j + 1] += dp[j] * ((i - j) * inv % MOD)
        ndp[j + 1] %= MOD
    dp = ndp

ans = 0
for i, d in enumerate(dp):    
    ans += d * (1 - pow(x + 1 - i, MOD - 2, MOD)) % MOD
    ans %= MOD

print(ans)
0