結果

問題 No.1989 Pairing Multiset
ユーザー vjudge1
提出日時 2025-09-30 22:00:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 294 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 1,673 ms
コンパイル使用メモリ 193,844 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-30 22:00:07
合計ジャッジ時間 6,927 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int kmaxn=5e5+10,mod=998244353;
int qr[kmaxn],ni[kmaxn];
int ksm(int x,int y){
    int w=1;
    for(int i=0;i<=30;i++){
        if(y&(1<<i))w=w*x%mod;
        x=x*x%mod;
    }
    return w;
}
int C(int x,int y){
    if(x<y||y<0)return 0;
    return qr[x]*ni[y]%mod*ni[x-y]%mod;
}
int CC(int x,int y){
    if(x<y||y<0)return 0;
    int an=1;
    for(int i=x;i>=x-y+1;i--){
        an=an*i%mod*ksm(x-i+1,mod-2)%mod;
    }
    return an;
}
int n,m;
signed main(){
//    freopen("main.in","r",stdin);
//    freopen("main.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    int ans=n*CC(2*n+m,2*n+1)%mod;
    cout<<ans<<"\n";
    return 0;
}
0