結果

問題 No.1856 Mex Sum 2
ユーザー pockynypockyny
提出日時 2022-02-26 15:36:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,142 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 117,268 KB
実行使用メモリ 19,556 KB
最終ジャッジ日時 2023-09-17 17:09:19
合計ジャッジ時間 39,554 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
19,208 KB
testcase_01 AC 8 ms
19,276 KB
testcase_02 AC 9 ms
19,216 KB
testcase_03 AC 8 ms
19,236 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 8 ms
19,384 KB
testcase_08 AC 7 ms
19,380 KB
testcase_09 AC 7 ms
19,208 KB
testcase_10 AC 7 ms
19,152 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 7 ms
19,152 KB
testcase_14 AC 7 ms
19,196 KB
testcase_15 WA -
testcase_16 AC 7 ms
19,332 KB
testcase_17 AC 9 ms
19,248 KB
testcase_18 AC 9 ms
19,232 KB
testcase_19 AC 7 ms
19,272 KB
testcase_20 AC 7 ms
19,356 KB
testcase_21 AC 7 ms
19,152 KB
testcase_22 AC 8 ms
19,160 KB
testcase_23 AC 7 ms
19,200 KB
testcase_24 AC 8 ms
19,152 KB
testcase_25 AC 8 ms
19,216 KB
testcase_26 AC 7 ms
19,192 KB
testcase_27 AC 7 ms
19,208 KB
testcase_28 AC 7 ms
19,152 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 927 ms
19,212 KB
testcase_43 AC 762 ms
19,536 KB
testcase_44 AC 831 ms
19,208 KB
testcase_45 AC 911 ms
19,260 KB
testcase_46 AC 767 ms
19,532 KB
testcase_47 AC 843 ms
19,216 KB
testcase_48 AC 945 ms
19,348 KB
testcase_49 AC 936 ms
19,556 KB
testcase_50 AC 645 ms
19,216 KB
testcase_51 AC 982 ms
19,376 KB
testcase_52 AC 979 ms
19,312 KB
testcase_53 AC 980 ms
19,272 KB
testcase_54 AC 981 ms
19,264 KB
testcase_55 AC 983 ms
19,312 KB
testcase_56 AC 984 ms
19,316 KB
testcase_57 AC 984 ms
19,288 KB
testcase_58 AC 984 ms
19,216 KB
testcase_59 AC 983 ms
19,264 KB
testcase_60 AC 981 ms
19,260 KB
testcase_61 AC 985 ms
19,344 KB
testcase_62 AC 983 ms
19,260 KB
testcase_63 AC 982 ms
19,332 KB
testcase_64 AC 980 ms
19,412 KB
testcase_65 AC 983 ms
19,200 KB
testcase_66 AC 982 ms
19,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/modint>
#include <atcoder/convolution>
#include <vector>

using namespace std;
using namespace atcoder;
using mint = modint998244353;
int mod = 998244353;
mint f[2010][2010],fa[2010],fi[2010];
mint pw(mint a,int x){
    mint ret = 1;
    while(x){
        if(x&1) (ret *= a);
        (a *= a); x /= 2;
    }
    return ret;
}

mint nck(int n,int k){
    if(n<0 || k<0 || n<k) return 0;
    return fa[n]*fi[k]*fi[n - k];
}

void solve(){
    int MX = 2010;
    fi[0] = fa[0] = 1;
    for(int i=1;i<MX;i++) fa[i] = fa[i - 1]*i;
    fi[MX - 1] = (mint)1/fa[MX - 1];
    for(int i=MX - 2;i>=1;i--) fi[i] = fi[i + 1]*(i + 1);
}

int main(){
    int i,j,k,x,n,m; cin >> n >> m;
    solve();
    for(k=0;k<=n;k++){
        vector<mint> g(n + 2),h(n + 2);
        for(j=0;j<=n + 1;j++) g[j] = pw(m + 1 - j,k)*pw(mod - 1,j)*fi[j];
        for(j=0;j<=n + 1;j++) h[j] = fi[j];
        g = convolution(g,h);
        for(j=0;j<=n + 1;j++) f[k][j] = pw(m + 1,n - k)*fa[j]*g[j];
    }
    mint ans = 0;
    for(i=1;i<=n + 1;i++){
        for(k=1;k<=n;k++) ans += nck(n,k)*f[k][i];
    }
    cout << ans.val() << endl;
}
0