結果

問題 No.2105 Avoid MeX
ユーザー chineristACchineristAC
提出日時 2022-10-21 21:53:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 495 ms / 2,000 ms
コード長 1,151 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 86,936 KB
最終ジャッジ日時 2023-09-13 22:12:47
合計ジャッジ時間 6,989 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
84,012 KB
testcase_01 AC 126 ms
84,120 KB
testcase_02 AC 130 ms
83,812 KB
testcase_03 AC 125 ms
83,684 KB
testcase_04 AC 294 ms
86,108 KB
testcase_05 AC 127 ms
83,784 KB
testcase_06 AC 191 ms
85,904 KB
testcase_07 AC 212 ms
85,960 KB
testcase_08 AC 154 ms
85,972 KB
testcase_09 AC 298 ms
86,208 KB
testcase_10 AC 129 ms
83,852 KB
testcase_11 AC 133 ms
84,132 KB
testcase_12 AC 164 ms
85,796 KB
testcase_13 AC 130 ms
83,808 KB
testcase_14 AC 201 ms
85,964 KB
testcase_15 AC 223 ms
86,392 KB
testcase_16 AC 129 ms
84,044 KB
testcase_17 AC 129 ms
83,872 KB
testcase_18 AC 129 ms
84,168 KB
testcase_19 AC 487 ms
86,936 KB
testcase_20 AC 486 ms
86,916 KB
testcase_21 AC 495 ms
86,936 KB
testcase_22 AC 477 ms
86,688 KB
testcase_23 AC 127 ms
83,716 KB
testcase_24 AC 133 ms
83,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.buffer.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

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

mod = 998244353
N = 2*10**5
g1 = [1]*(N+1)
g2 = [1]*(N+1)
inverse = [1]*(N+1)

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

C,X = mi()

if X == 0:
    print(inverse[C+1])
    exit()

dp = [0] * (X+1)
dp[0] = 1
for i in range(X-C):
    ndp = [0] * (X+1)
    for j in range(X+1):
        ALL = C+i+1
        NEW = ALL - j
        if j!=X:
            ndp[j+1] += dp[j] * NEW * inverse[ALL] % mod
            ndp[j+1] %= mod
        ndp[j] += dp[j] * (j) * inverse[ALL] % mod
        ndp[j] %= mod
    dp = ndp

res = 0
for j in range(X+1):
    rest = X+1 - j
    res += dp[j] * (1 - inverse[rest]) % mod
    res %= mod

print(res)
0