結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー wanui
提出日時 2022-11-25 22:27:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,905 bytes
コンパイル時間 2,023 ms
コンパイル使用メモリ 195,004 KB
最終ジャッジ日時 2025-02-09 00:30:42
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30 WA * 8
権限があれば一括ダウンロードができます

ソースコード

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