結果

問題 No.1856 Mex Sum 2
ユーザー 👑 colognecologne
提出日時 2022-02-28 17:02:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 709 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-21 01:26:04
合計ジャッジ時間 8,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,816 KB
testcase_01 AC 16 ms
7,788 KB
testcase_02 AC 177 ms
7,908 KB
testcase_03 AC 16 ms
7,812 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 35 ms
7,908 KB
testcase_08 AC 15 ms
7,808 KB
testcase_09 AC 16 ms
7,872 KB
testcase_10 AC 17 ms
7,876 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 16 ms
7,932 KB
testcase_14 AC 15 ms
7,884 KB
testcase_15 RE -
testcase_16 AC 18 ms
7,748 KB
testcase_17 AC 92 ms
7,756 KB
testcase_18 AC 59 ms
7,812 KB
testcase_19 AC 19 ms
7,860 KB
testcase_20 AC 18 ms
7,860 KB
testcase_21 AC 15 ms
7,952 KB
testcase_22 AC 108 ms
7,904 KB
testcase_23 AC 16 ms
7,788 KB
testcase_24 AC 52 ms
7,736 KB
testcase_25 AC 98 ms
7,784 KB
testcase_26 AC 15 ms
7,740 KB
testcase_27 AC 15 ms
7,840 KB
testcase_28 AC 15 ms
7,820 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 TLE -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    MOD = 998244353

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

    f = [0] * (min(N, M+1)+1)
    for mex in range(1, min(N, M+1)+1):
        DP = [1] + [0] * mex
        for i in range(1, N+1):
            NDP = [0] * (mex + 1)
            for j in range(mex+1):
                NDP[j] = (NDP[j] + ((M+1) - (mex-j)) * DP[j]) % MOD
                if mex != j:
                    NDP[j+1] = (NDP[j+1] + (mex-j) * DP[j]) % MOD
            DP = NDP
            f[i] = (f[i] + DP[-1]) % MOD

    ans = 0
    C = 1
    for i in range(1, N+1):
        C = C * (N-i+1) * pow(i, -1, MOD) % MOD
        ans = (ans + pow(M+1, N-i, MOD) * C * f[i]) % MOD

    print(ans)


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