結果

問題 No.1856 Mex Sum 2
ユーザー boatmusclesboatmuscles
提出日時 2022-02-26 16:06:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 50,320 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-17 17:45:21
合計ジャッジ時間 2,593 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,376 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 2 ms
4,376 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 2 ms
4,376 KB
testcase_64 AC 1 ms
4,380 KB
testcase_65 AC 1 ms
4,376 KB
testcase_66 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<algorithm>
#include<atcoder/modint>
using namespace atcoder;
using Mint = modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    Mint answer = -(Mint((M+1)<<1).pow(N));
    Mint fact[N+3];
    fact[0] = Mint::raw(1);
    for (int i = 1; i <= N+2; i++) fact[i] = fact[i-1]*Mint::raw(i);
    Mint ifact[N+3];
    ifact[N+2] = fact[N+2].inv();
    for (int i = N+2; (i); i--) ifact[i-1] = ifact[i]*Mint::raw(i);
    for (int i = 0, lim = std::min(M+1, N); i <= lim; i++)
    {
        if(i&1) answer -= Mint((M<<1)-i+1).pow(N)*fact[lim+2]*ifact[i+2]*ifact[lim-i]*Mint::raw(i+1);
        else answer += Mint((M<<1)-i+1).pow(N)*fact[lim+2]*ifact[i+2]*ifact[lim-i]*Mint::raw(i+1);
    }
    printf("%u\n", answer.val());
    return 0;
}
0