結果

問題 No.2199 lower_bound and upper_bound
ユーザー umimelumimel
提出日時 2023-02-13 16:57:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 165,368 KB
実行使用メモリ 15,640 KB
最終ジャッジ日時 2023-09-23 11:35:16
合計ジャッジ時間 3,726 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
15,336 KB
testcase_01 AC 18 ms
15,300 KB
testcase_02 AC 18 ms
15,308 KB
testcase_03 AC 18 ms
15,472 KB
testcase_04 AC 17 ms
15,640 KB
testcase_05 AC 18 ms
15,576 KB
testcase_06 AC 19 ms
15,312 KB
testcase_07 AC 18 ms
15,464 KB
testcase_08 AC 18 ms
15,368 KB
testcase_09 AC 19 ms
15,392 KB
testcase_10 AC 19 ms
15,332 KB
testcase_11 AC 18 ms
15,316 KB
testcase_12 AC 18 ms
15,312 KB
testcase_13 AC 19 ms
15,352 KB
testcase_14 AC 18 ms
15,388 KB
testcase_15 AC 18 ms
15,332 KB
testcase_16 AC 18 ms
15,332 KB
testcase_17 AC 19 ms
15,404 KB
testcase_18 AC 19 ms
15,464 KB
testcase_19 AC 18 ms
15,360 KB
testcase_20 AC 18 ms
15,600 KB
testcase_21 AC 18 ms
15,300 KB
testcase_22 AC 18 ms
15,320 KB
testcase_23 AC 18 ms
15,320 KB
testcase_24 AC 19 ms
15,400 KB
権限があれば一括ダウンロードができます

ソースコード

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(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll N, L, U;
    cin >> N >> L >> U;

    cominit();
    ll ans = 0;
    for(ll i=L+N; i<=U+N; i++){
        if(i < U+2){
            ans = (ans + com((N-1)+i, i))%MOD;
        }else{
            ll sa = (com((N-1)+i, i) - com((N-1)+i, i-(U+2))+MOD)%MOD;
            ans = (ans + sa)%MOD;
        }
    }

    cout << ans << endl;
}
0