結果

問題 No.2058 Binary String
ユーザー やうやう
提出日時 2022-08-26 22:24:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 1,897 ms
コンパイル使用メモリ 164,596 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-22 00:30:12
合計ジャッジ時間 7,731 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
6,528 KB
testcase_01 AC 137 ms
6,528 KB
testcase_02 AC 154 ms
6,272 KB
testcase_03 AC 136 ms
6,528 KB
testcase_04 AC 135 ms
6,528 KB
testcase_05 AC 152 ms
6,400 KB
testcase_06 AC 144 ms
6,528 KB
testcase_07 AC 205 ms
6,400 KB
testcase_08 AC 150 ms
6,272 KB
testcase_09 AC 212 ms
6,528 KB
testcase_10 AC 164 ms
6,400 KB
testcase_11 AC 152 ms
6,272 KB
testcase_12 AC 175 ms
6,400 KB
testcase_13 AC 166 ms
6,528 KB
testcase_14 AC 156 ms
6,272 KB
testcase_15 AC 161 ms
6,400 KB
testcase_16 AC 163 ms
6,272 KB
testcase_17 AC 160 ms
6,272 KB
testcase_18 AC 139 ms
6,528 KB
testcase_19 AC 208 ms
6,400 KB
testcase_20 AC 194 ms
6,400 KB
testcase_21 AC 206 ms
6,400 KB
testcase_22 AC 204 ms
6,528 KB
testcase_23 AC 210 ms
6,272 KB
testcase_24 AC 216 ms
6,400 KB
testcase_25 AC 218 ms
6,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

}
0