結果

問題 No.2130 分配方法の数え上げ mod 998244353
ユーザー twooimp2twooimp2
提出日時 2024-02-24 19:03:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 6,371 ms
コンパイル使用メモリ 300,204 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-24 19:03:55
合計ジャッジ時間 8,337 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 AC 4 ms
6,676 KB
testcase_20 AC 2 ms
6,676 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 1 ms
6,676 KB
testcase_29 WA -
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 3 ms
6,676 KB
testcase_37 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;

void IO(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n&1){
      res=res*a%mod;
    }
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll m){
	ll b=m,u=1,v=0;
	while(b){
		ll t=a/b;
		a-=t*b;
		swap(a,b);
		u-=t*v;
		swap(u,v);
	}
	u%=m;
	if(u<0) u+=m;
	return u;
}

int main(){
  IO();
  ll n;
  cin>>n;
  ll m;
  cin>>m;
  if(n<m){
    cout<<0<<endl;
    exit(0);
  }
  ll mod=998244353;
  ll ans=modpow(2,n,mod);
  ll num=1;
  for(ll i=0;i<m;i++){
    ans-=num; ans+=mod; ans%=mod;
    num*=n-i; num%=mod;
    num*=modinv(i+1,mod); num%=mod;
  }
  cout<<ans<<endl;
}
0