結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー wanuiwanui
提出日時 2022-11-25 22:27:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,905 bytes
コンパイル時間 3,576 ms
コンパイル使用メモリ 196,812 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 03:39:41
合計ジャッジ時間 3,581 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 5 ms
6,940 KB
testcase_19 AC 5 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 WA -
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }
#define debug1(a) { cerr<<#a<<":"<<a<<endl; }
#define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; }
#define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; }
#define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; }
// clang-format on
const ll MODULO = 998244353;
ll _mpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    }
    ll y = _mpow(x, n / 2);
    y = y * y % MODULO;
    if (n & 1) {
        y = y * x % MODULO;
    }
    return y;
}
ll mpow(ll x, ll n) {
    return _mpow(x % MODULO, n);
}
ll nC[100005];
void set_combination(ll n, ll k) {
    nC[0] = 1;
    for (ll i = 1; i <= k; i++) {
        ll ans = nC[i - 1];
        ans = (ans * mpow(i, MODULO - 2)) % MODULO;
        ans = ans * (n - i + 1) % MODULO;
        nC[i] = ans;
    }
}

int main() {
    ioinit();
    ll N, M;
    cin >> N >> M;
    if (N < M) {
        print(0);
        return 0;
    }
    set_combination(N, M);
    ll ans = mpow(2, N);
    for (ll i = 0; i <= M - 1; i++) {
        ans -= nC[i];
    }
    ans %= MODULO;
    if (ans < 0) ans += MODULO;
    print(ans);
    return 0;
}
0