結果

問題 No.2472 Tea time in the grand garden
ユーザー Yerin JungYerin Jung
提出日時 2023-09-24 01:07:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 1,573 ms
コンパイル使用メモリ 166,220 KB
実行使用メモリ 9,888 KB
最終ジャッジ日時 2023-09-24 01:07:14
合計ジャッジ時間 4,134 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
9,888 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 7 ms
9,744 KB
testcase_03 AC 10 ms
9,796 KB
testcase_04 AC 7 ms
9,884 KB
testcase_05 AC 7 ms
9,684 KB
testcase_06 AC 6 ms
9,608 KB
testcase_07 AC 7 ms
9,812 KB
testcase_08 AC 6 ms
9,592 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 6 ms
9,684 KB
testcase_13 AC 7 ms
9,624 KB
testcase_14 AC 10 ms
9,868 KB
testcase_15 AC 10 ms
9,676 KB
testcase_16 AC 6 ms
9,792 KB
testcase_17 AC 7 ms
9,788 KB
testcase_18 AC 6 ms
9,580 KB
testcase_19 AC 6 ms
9,572 KB
testcase_20 AC 7 ms
9,732 KB
testcase_21 AC 7 ms
9,616 KB
testcase_22 AC 6 ms
9,676 KB
testcase_23 AC 6 ms
9,744 KB
testcase_24 AC 7 ms
9,816 KB
testcase_25 AC 7 ms
9,604 KB
testcase_26 AC 8 ms
9,744 KB
testcase_27 AC 6 ms
9,592 KB
testcase_28 AC 8 ms
9,608 KB
testcase_29 AC 8 ms
9,636 KB
testcase_30 AC 8 ms
9,604 KB
testcase_31 AC 7 ms
9,744 KB
testcase_32 AC 9 ms
9,660 KB
testcase_33 AC 9 ms
9,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const ll mod=998244353;
const int iu=4e5+4;
ll n,k;
ll f[iu+1],inf[iu+1];
ll pw(ll x,ll y){
	if(y==0) return 1;
	if(y%2) return x*pw(x,y-1)%mod;
	ll res=pw(x,y/2);
	return res*res%mod;
}
ll C(ll x,ll y){
	return f[x]*inf[y]%mod*inf[x-y]%mod;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin >> n >> k;n++;
	if(k==0) return cout << "1\n",0;
	f[0]=1;
	for(int i=1; i<=iu ;i++) f[i]=f[i-1]*i%mod;
	inf[iu]=pw(f[iu],mod-2);
	for(int i=iu; i>=1 ;i--) inf[i-1]=inf[i]*i%mod;
	ll ans=0;
	for(int i=1; i<n ;i++){//number of +
		if(n-i>k+1) continue;
		ll ways=C(n,i)*C(k+i-1,i-1)%mod*C(k,n-i-1)%mod;
		ways=ways*f[n-1]%mod*inf[n]%mod;
		ans=(ans+ways)%mod;
	}
	cout << ans << '\n';
}
0