結果
| 問題 | No.2130 分配方法の数え上げ mod 998244353 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-25 21:24:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 2,000 ms |
| コード長 | 734 bytes |
| コンパイル時間 | 2,106 ms |
| コンパイル使用メモリ | 210,284 KB |
| 最終ジャッジ日時 | 2025-02-08 23:42:59 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 38 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
constexpr ll mod = 998244353;
ll mod_pow(ll a,ll b){
a%=mod;
if(b==0)return 1;
if(b==1)return a;
ll res=mod_pow(a,b/2)%mod;
res*=res; res%=mod;
if(b%2)res*=a;
return res%mod;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n,m; cin >> n >> m;
if(n<m){
cout << 0 << endl;
return 0;
}
ll res = mod_pow(2, n);
ll sub = 1;
for(int i=0;i<m;i++){
// res -= p.comb(n,i)
res -= sub;
sub *= (n-i)%mod; sub %= mod;
sub *= mod_pow(i+1, mod-2); sub %= mod;
}
res %= mod;
cout << (res+mod)%mod << endl;
}