結果
| 問題 |
No.2058 Binary String
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-26 23:02:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 750 bytes |
| コンパイル時間 | 2,111 ms |
| コンパイル使用メモリ | 193,640 KB |
| 最終ジャッジ日時 | 2025-01-31 05:30:13 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
long long fac[200005];
long long invf[200005];
long long inv[200005];
long long modpow(int a,int n){
long long ret=1,t=a;
for(int i=0;i<30;i++){
if(n>>i&1)ret=ret*t%mod;
t=t*t%mod;
}
return ret;
}
long long modcomb(int n,int r){
return fac[n]*invf[r]%mod*invf[n-r]%mod;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
fac[0]=inv[0]=invf[0]=1;
fac[1]=inv[1]=invf[1]=1;
for(int i=2;i<=200000;i++){
fac[i]=fac[i-1]*i%mod;
inv[i]=inv[mod%i]*(mod-mod/i)%mod;
invf[i]=invf[i-1]*inv[i]%mod;
}
int N,K;
cin>>N>>K;
long long ans=0;
for(int i=1;i<N;i++){
ans=(ans+modpow(i,K)*modcomb(N-1,i))%mod;
}
cout<<ans<<'\n';
}