結果
問題 | No.2130 分配方法の数え上げ mod 998244353 |
ユーザー |
|
提出日時 | 2024-02-24 19:05:01 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 879 bytes |
コンパイル時間 | 6,100 ms |
コンパイル使用メモリ | 300,356 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-09-29 10:13:25 |
合計ジャッジ時間 | 6,755 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 8 |
ソースコード
#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; while(ans<0){ans+=mod;} ans%=mod; num*=n-i; num%=mod; num*=modinv(i+1,mod); num%=mod; } cout<<ans<<endl; }