結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー cho435cho435
提出日時 2022-11-25 22:26:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 198,832 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-04-10 03:37:55
合計ジャッジ時間 3,768 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,936 KB
testcase_01 AC 7 ms
7,936 KB
testcase_02 AC 8 ms
7,936 KB
testcase_03 AC 8 ms
7,936 KB
testcase_04 AC 8 ms
7,936 KB
testcase_05 AC 7 ms
7,936 KB
testcase_06 AC 8 ms
8,064 KB
testcase_07 AC 8 ms
7,936 KB
testcase_08 AC 8 ms
7,808 KB
testcase_09 AC 8 ms
7,936 KB
testcase_10 AC 8 ms
7,936 KB
testcase_11 AC 8 ms
7,936 KB
testcase_12 AC 8 ms
7,936 KB
testcase_13 AC 9 ms
8,064 KB
testcase_14 AC 8 ms
8,064 KB
testcase_15 AC 8 ms
7,936 KB
testcase_16 AC 8 ms
7,808 KB
testcase_17 AC 8 ms
8,064 KB
testcase_18 AC 9 ms
7,936 KB
testcase_19 AC 8 ms
7,936 KB
testcase_20 AC 8 ms
7,936 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 8 ms
8,192 KB
testcase_29 WA -
testcase_30 AC 9 ms
7,936 KB
testcase_31 AC 8 ms
7,936 KB
testcase_32 AC 8 ms
7,936 KB
testcase_33 AC 10 ms
7,936 KB
testcase_34 AC 8 ms
8,064 KB
testcase_35 AC 9 ms
7,936 KB
testcase_36 AC 8 ms
8,064 KB
testcase_37 AC 8 ms
7,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(int)(n);i++)

const int MOD=998244353;
const int MAX_N=2e5;
vector<ll> fac(MAX_N+1,1);
vector<ll> finv(MAX_N+1,1);
vector<ll> inv(MAX_N+1,1);
void comb_setup(){
  for(int i=2;i<=MAX_N;i++){
    fac.at(i)=(fac.at(i-1)*i)%MOD;
    inv.at(i)=MOD-(inv.at(MOD%i)*(MOD/i))%MOD;
    finv.at(i)=(finv.at(i-1)*inv.at(i))%MOD;
  }
}
ll comb(ll n,ll k){
  if(n<k) return 0;
  n%=MOD;
  k%=MOD;
  return fac.at(n)*(finv.at(n-k)*finv.at(k)%MOD)%MOD;
}

ll mpow(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%MOD;
    a=a*a%MOD;
    n>>=1;
  }
  return ans;
}

int main(){
  comb_setup();
  ll n,m;
  cin>>n>>m;
  if(n<m){
    cout<<0<<endl;
    return 0;
  }
  ll nw=0;
  ll tmp=1;
  rep(i,m){
    nw=(nw+tmp)%MOD;
    tmp*=n-i;
    tmp%=MOD;
    tmp*=inv.at(i+1);
    tmp%=MOD;
  }
  cout<<(mpow(2,n)-nw+MOD)%MOD<<endl;
}
0