結果

問題 No.2199 lower_bound and upper_bound
ユーザー 👑 potato167potato167
提出日時 2023-01-21 02:45:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 200,480 KB
実行使用メモリ 10,312 KB
最終ジャッジ日時 2023-09-05 18:41:34
合計ジャッジ時間 4,125 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,004 KB
testcase_01 AC 26 ms
10,168 KB
testcase_02 AC 26 ms
10,168 KB
testcase_03 AC 26 ms
10,148 KB
testcase_04 AC 29 ms
10,212 KB
testcase_05 AC 26 ms
10,168 KB
testcase_06 AC 26 ms
10,152 KB
testcase_07 AC 27 ms
10,240 KB
testcase_08 AC 27 ms
10,184 KB
testcase_09 AC 27 ms
10,156 KB
testcase_10 AC 28 ms
10,244 KB
testcase_11 AC 27 ms
10,220 KB
testcase_12 AC 25 ms
10,156 KB
testcase_13 AC 32 ms
10,172 KB
testcase_14 AC 27 ms
10,072 KB
testcase_15 AC 26 ms
10,056 KB
testcase_16 AC 27 ms
10,072 KB
testcase_17 AC 28 ms
10,168 KB
testcase_18 AC 28 ms
10,216 KB
testcase_19 AC 30 ms
10,144 KB
testcase_20 AC 29 ms
10,096 KB
testcase_21 AC 29 ms
10,100 KB
testcase_22 AC 26 ms
10,000 KB
testcase_23 AC 29 ms
10,312 KB
testcase_24 AC 30 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
using ll = long long;
#define all(p) p.begin(),p.end()

namespace po167{
struct combination{
	int upper;
	long long MOD;
	std::vector<long long> fact;
	std::vector<long long> rev;
	std::vector<long long> fact_rev;
	combination(int max,long long mod):upper(max),MOD(mod),fact(max+1),rev(max+1),fact_rev(max+1){
		for(long long i=0;i<=max;i++){
			if(i<2){
				fact[i]=1;
				fact_rev[i]=1;
				rev[i]=1;
				continue;
			}
			fact[i]=(fact[i-1]*i)%mod;
			rev[i]=mod-((mod/i)*rev[mod%i])%mod;
			fact_rev[i]=(fact_rev[i-1]*rev[i])%mod;
		}
	}
	long long Comb(int x,int y){
		assert(upper>=x);
		if (x<y||y<0||x<0) return 0;
		return (((fact_rev[y]*fact_rev[x-y])%MOD)*fact[x])%MOD;
	}
	long long P(int x,int y){
		assert(upper>=x);
		if (x<y||y<0||x<0) return 0;
		return (fact_rev[x-y]*fact[x])%MOD;
	}
};
}
using po167::combination;



int main(){
	ll N,L,U;
	cin>>N>>L>>U;
	const int mod=998244353;
	combination table(300'000,mod);
	ll ans=0;
	rep(i,L+N,U+N+1){
		ans+=table.Comb(i+N-1,i);
		ans-=table.Comb(i+N-1,U+1+N);
	}
	cout<<(ans%mod+mod)%mod<<"\n";
}
0