結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー FplusFplusF
提出日時 2022-11-25 21:38:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,102 bytes
コンパイル時間 1,837 ms
コンパイル使用メモリ 196,552 KB
最終ジャッジ日時 2025-02-09 00:02:38
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i=0;i<(long long)(n);i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
ll modpow(ll a,ll b,ll mod){
    if(b==0) return 1;
    ll p=a,ret=1;
    for(ll i=0;i<=62;i++){
        if(b&(1ll<<i)){
            ret*=p;
            ret%=mod;
        }
        p=(p%mod)*(p%mod);
        p%=mod;
    }
    return ret;
}
ll division(ll a,ll b,ll mod){
    return (a*modpow(b,mod-2,mod))%mod;
}
map<ll,map<ll,ll>> factorial;
int main(){
    const ll mod=998244353;
    ll n,m;
    cin >> n >> m;
    n%=mod;
    m%=mod;
    ll sum=0;
    ll r=1;
    for(ll i=0;i<min(n+1,m);i++){
        if(i==0) sum+=1;
        else{
            r*=(n-i)+1;
            r%=mod;
            r=division(r,i,mod);
            sum+=r;
            sum%=mod;
        }
    }
    cout << (modpow(2,n,mod)-sum+mod)%mod << endl;
}
0