結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー umimelumimel
提出日時 2022-11-25 21:25:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,071 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 163,484 KB
実行使用メモリ 15,592 KB
最終ジャッジ日時 2024-04-10 02:34:11
合計ジャッジ時間 8,697 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
15,492 KB
testcase_01 AC 14 ms
15,592 KB
testcase_02 AC 15 ms
15,564 KB
testcase_03 AC 13 ms
15,420 KB
testcase_04 AC 14 ms
15,496 KB
testcase_05 AC 16 ms
15,508 KB
testcase_06 AC 14 ms
15,512 KB
testcase_07 AC 15 ms
15,544 KB
testcase_08 AC 14 ms
15,484 KB
testcase_09 AC 15 ms
15,496 KB
testcase_10 AC 15 ms
15,436 KB
testcase_11 AC 15 ms
15,564 KB
testcase_12 AC 15 ms
15,464 KB
testcase_13 AC 14 ms
15,448 KB
testcase_14 AC 16 ms
15,564 KB
testcase_15 AC 15 ms
15,504 KB
testcase_16 AC 15 ms
15,444 KB
testcase_17 AC 14 ms
15,564 KB
testcase_18 AC 13 ms
15,468 KB
testcase_19 AC 15 ms
15,556 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
 
void cominit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
 
ll com(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
    ll n, m;
    cin >> n >> m;

    cominit();
    if(n < m){
        cout << 0 << endl;
    }else{
        ll ans = 0;
        for(ll i=m; i<=n; i++){
            ans += com(n, i);
            ans %= MOD;
        }

        cout << ans << endl;
    }
}
0