結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー FplusFplusFFplusFplusF
提出日時 2022-11-25 21:23:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,311 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 208,892 KB
実行使用メモリ 72,996 KB
最終ジャッジ日時 2024-04-10 02:32:48
合計ジャッジ時間 15,795 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 365 ms
72,996 KB
testcase_01 AC 361 ms
66,048 KB
testcase_02 AC 350 ms
66,048 KB
testcase_03 AC 359 ms
65,920 KB
testcase_04 AC 362 ms
66,048 KB
testcase_05 AC 364 ms
66,176 KB
testcase_06 AC 354 ms
65,920 KB
testcase_07 AC 361 ms
66,048 KB
testcase_08 AC 353 ms
65,920 KB
testcase_09 AC 346 ms
66,048 KB
testcase_10 AC 350 ms
65,920 KB
testcase_11 AC 360 ms
65,920 KB
testcase_12 AC 360 ms
65,920 KB
testcase_13 AC 356 ms
66,048 KB
testcase_14 AC 357 ms
66,048 KB
testcase_15 AC 360 ms
66,048 KB
testcase_16 AC 358 ms
66,048 KB
testcase_17 AC 365 ms
65,920 KB
testcase_18 AC 371 ms
65,920 KB
testcase_19 AC 375 ms
66,048 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
ll nCr(ll n,ll r,ll mod){
    if(n<0||r<0) return 0;
    if(n<r) return 0;
    if(factorial[mod][n]==0){
        ll x=1;
        factorial[mod][0]=1;
        for(ll i=1;i<=1000010;i++){    //iの上限は適宜変更
            x*=i;
            x%=mod;
            factorial[mod][i]=x;
        }
    }
    return division(factorial[mod][n],factorial[mod][r]*factorial[mod][n-r],mod);
}
int main(){
    const ll mod=998244353;
    ll n,m;
    cin >> n >> m;
    ll sum=0;
    rep(i,m){
        sum+=nCr(n,i,mod);
        sum%=mod;
    }
    cout << (modpow(2,n,mod)-sum+mod)%mod << endl;
}
0