結果

問題 No.1856 Mex Sum 2
ユーザー 👑 colognecologne
提出日時 2022-02-28 17:46:17
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 904 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 79,832 KB
最終ジャッジ日時 2023-09-21 02:12:35
合計ジャッジ時間 57,667 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,444 KB
testcase_01 AC 73 ms
71,468 KB
testcase_02 AC 95 ms
76,284 KB
testcase_03 AC 77 ms
71,348 KB
testcase_04 AC 74 ms
71,308 KB
testcase_05 AC 75 ms
71,280 KB
testcase_06 AC 78 ms
71,424 KB
testcase_07 AC 89 ms
76,220 KB
testcase_08 AC 77 ms
71,448 KB
testcase_09 AC 75 ms
71,388 KB
testcase_10 AC 78 ms
75,364 KB
testcase_11 AC 76 ms
71,120 KB
testcase_12 AC 75 ms
71,472 KB
testcase_13 AC 75 ms
71,204 KB
testcase_14 AC 75 ms
71,352 KB
testcase_15 AC 76 ms
71,252 KB
testcase_16 AC 81 ms
75,404 KB
testcase_17 AC 95 ms
76,128 KB
testcase_18 AC 91 ms
76,272 KB
testcase_19 AC 79 ms
75,400 KB
testcase_20 AC 78 ms
75,472 KB
testcase_21 AC 77 ms
75,608 KB
testcase_22 AC 94 ms
76,132 KB
testcase_23 AC 77 ms
75,472 KB
testcase_24 AC 90 ms
76,112 KB
testcase_25 AC 94 ms
76,272 KB
testcase_26 AC 75 ms
71,224 KB
testcase_27 AC 74 ms
71,316 KB
testcase_28 AC 78 ms
75,396 KB
testcase_29 AC 213 ms
77,288 KB
testcase_30 AC 136 ms
77,556 KB
testcase_31 AC 191 ms
77,572 KB
testcase_32 AC 301 ms
77,304 KB
testcase_33 AC 323 ms
77,320 KB
testcase_34 AC 193 ms
77,584 KB
testcase_35 AC 140 ms
77,028 KB
testcase_36 AC 115 ms
77,656 KB
testcase_37 AC 192 ms
77,080 KB
testcase_38 AC 109 ms
77,208 KB
testcase_39 AC 97 ms
76,648 KB
testcase_40 AC 97 ms
76,548 KB
testcase_41 AC 94 ms
76,680 KB
testcase_42 AC 2,120 ms
77,492 KB
testcase_43 AC 1,584 ms
77,428 KB
testcase_44 AC 1,911 ms
77,652 KB
testcase_45 AC 2,257 ms
77,380 KB
testcase_46 AC 1,843 ms
77,340 KB
testcase_47 AC 1,999 ms
77,236 KB
testcase_48 AC 2,204 ms
77,496 KB
testcase_49 AC 2,082 ms
77,632 KB
testcase_50 AC 1,475 ms
77,664 KB
testcase_51 AC 2,069 ms
77,316 KB
testcase_52 AC 2,042 ms
77,460 KB
testcase_53 AC 2,081 ms
77,532 KB
testcase_54 AC 2,050 ms
77,492 KB
testcase_55 AC 2,206 ms
77,376 KB
testcase_56 AC 2,063 ms
77,336 KB
testcase_57 AC 2,110 ms
77,164 KB
testcase_58 AC 2,334 ms
77,324 KB
testcase_59 AC 2,287 ms
77,396 KB
testcase_60 AC 2,233 ms
77,292 KB
testcase_61 AC 2,255 ms
77,480 KB
testcase_62 AC 1,985 ms
77,552 KB
testcase_63 AC 2,371 ms
77,536 KB
testcase_64 AC 2,063 ms
77,604 KB
testcase_65 AC 2,079 ms
77,424 KB
testcase_66 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    MOD = 998244353

    N, M = map(int, input().split())

    f = [0] * (min(N, M+1) + 1)
    DP = [1] + [0] * min(N, M+1)
    C = 1
    for iter in range(1, N+1):
        C = C * (N-iter+1) * pow(iter, -1, MOD) % MOD
        mult = pow(M+1, N-iter, MOD) * C % MOD
        for i in range(min(N, M+1), -1, -1):
            DP[i] = (
                i * DP[i] +
                ((M+1)-(i-1)) * (DP[i-1] if i != 0 else 0)
            ) % MOD
        f = [(f[i] + mult * DP[i]) % MOD for i in range(min(N, M+1)+1)]

    ans = 0
    for i in range(1, min(N, M+1)+1):
        mult = (M+1-i) * pow(M+1, -1, MOD) % MOD
        for mex in range(1, i+1):
            if mex == M+1:
                mult = 1
            else:
                mult = mult * (i-mex+1) * pow(M-mex+1, -1, MOD) % MOD
            ans = (ans + mex * mult * f[i]) % MOD

    print(ans)


if __name__ == '__main__':
    main()
0