結果
問題 | No.2058 Binary String |
ユーザー |
![]() |
提出日時 | 2022-08-26 22:24:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 215 ms / 2,000 ms |
コード長 | 757 bytes |
コンパイル時間 | 1,591 ms |
コンパイル使用メモリ | 168,528 KB |
実行使用メモリ | 6,528 KB |
最終ジャッジ日時 | 2024-10-13 23:02:20 |
合計ジャッジ時間 | 6,917 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll=long long;using ld=long double;using P=pair<ll,ll>;using V=vector<ll>;#define rep(i,n) for(int i=0;i<n;i++)#define REP(i,n) for(int i=1;i<=n;i++)ll p=998244353,siz=2*1e5;V a(siz),b(siz);ll powk(ll k,ll n){ll ans=1,m=k%p;if(m==0) return 0;while(n){if(n%2) ans=ans*m%p;m=m*m%p; n/=2;}return ans;}void comb1(){a[0]=1;for(ll i=1;i<siz;i++) a[i]=a[i-1]*i%p;rep(i,siz) b[i]=powk(a[i],p-2);return;}ll comb(int n,int k){return a[n]*b[n-k]%p*b[k]%p;}int main(){comb1();ll n,k;cin >> n >> k;ll ans=0;rep(i,n){ans+=powk(i,k)*comb(n-1,i);ans%=p;}cout << ans << endl;}