結果
問題 | No.2472 Tea time in the grand garden |
ユーザー |
|
提出日時 | 2023-09-24 01:07:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 788 bytes |
コンパイル時間 | 1,582 ms |
コンパイル使用メモリ | 168,388 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-07-17 01:02:16 |
合計ジャッジ時間 | 3,002 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef long long ll;#define fi first#define se secondconst 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';}