結果

問題 No.2199 lower_bound and upper_bound
ユーザー 👑 NachiaNachia
提出日時 2023-01-20 21:30:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 2,241 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 83,256 KB
実行使用メモリ 11,044 KB
最終ジャッジ日時 2023-09-05 13:39:23
合計ジャッジ時間 2,406 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
10,904 KB
testcase_01 AC 16 ms
10,960 KB
testcase_02 AC 15 ms
10,836 KB
testcase_03 AC 16 ms
10,964 KB
testcase_04 AC 15 ms
10,784 KB
testcase_05 AC 15 ms
10,804 KB
testcase_06 AC 15 ms
10,896 KB
testcase_07 AC 14 ms
10,776 KB
testcase_08 AC 15 ms
10,896 KB
testcase_09 AC 15 ms
10,800 KB
testcase_10 AC 15 ms
10,780 KB
testcase_11 AC 15 ms
10,852 KB
testcase_12 AC 15 ms
10,780 KB
testcase_13 AC 16 ms
10,880 KB
testcase_14 AC 14 ms
10,784 KB
testcase_15 AC 14 ms
10,836 KB
testcase_16 AC 15 ms
10,852 KB
testcase_17 AC 14 ms
11,044 KB
testcase_18 AC 15 ms
10,784 KB
testcase_19 AC 16 ms
10,928 KB
testcase_20 AC 16 ms
10,792 KB
testcase_21 AC 15 ms
10,804 KB
testcase_22 AC 15 ms
10,856 KB
testcase_23 AC 15 ms
10,832 KB
testcase_24 AC 15 ms
10,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "Main.cpp"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
#line 3 "nachia\\math\\combination.hpp"

namespace nachia{

template<class Modint>
class Comb{
private:
    std::vector<Modint> F;
    std::vector<Modint> iF;
public:
    void extend(int newN){
        int prevN = (int)F.size() - 1;
        if(prevN >= newN) return;
        F.resize(newN+1);
        iF.resize(newN+1);
        for(int i=prevN+1; i<=newN; i++) F[i] = F[i-1] * Modint::raw(i);
        iF[newN] = F[newN].inv();
        for(int i=newN; i>prevN; i--) iF[i-1] = iF[i] * Modint::raw(i);
    }
    Comb(int n = 1){
        F.assign(2, Modint(1));
        iF.assign(2, Modint(1));
        extend(n);
    }
    Modint factorial(int n) const { return F[n]; }
    Modint invFactorial(int n) const { return iF[n]; }
    Modint invOf(int n) const { return iF[n] * F[n-1]; }
    Modint comb(int n, int r) const {
        if(n < 0 || n < r || r < 0) return Modint(0);
        return F[n] * iF[r] * iF[n-r];
    }
    Modint invComb(int n, int r) const {
        if(n < 0 || n < r || r < 0) return Modint(0);
        return iF[n] * F[r] * F[n-r];
    }
    Modint perm(int n, int r) const {
        if(n < 0 || n < r || r < 0) return Modint(0);
        return F[n] * iF[n-r];
    }
    Modint invPerm(int n, int r) const {
        if(n < 0 || n < r || r < 0) return Modint(0);
        return iF[n] * F[n-r];
    }
    Modint operator()(int n, int r) const { return comb(n,r); }
};

} // namespace nachia
#line 7 "Main.cpp"
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;


int main(){
    int N; cin >> N;
    int L, U; cin >> L >> U;
    nachia::Comb<Modint> C(1000000);
    Modint ans = 0;
    for(int i=N+L; i<=N+U; i++){
        int d = N+U-i+1;
        ans += C.comb(N-1+i, N-1);
        ans -= C.comb(N-1+i, N-1-d);
    }
    cout << ans.val() << endl;
    return 0;
}



struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;

0