結果

問題 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,528 ms
コンパイル使用メモリ 168,028 KB
実行使用メモリ 6,288 KB
最終ジャッジ日時 2023-08-04 01:57:25
合計ジャッジ時間 7,089 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
6,092 KB
testcase_01 AC 137 ms
6,168 KB
testcase_02 AC 154 ms
6,072 KB
testcase_03 AC 137 ms
5,972 KB
testcase_04 AC 137 ms
6,276 KB
testcase_05 AC 137 ms
5,972 KB
testcase_06 AC 140 ms
6,216 KB
testcase_07 AC 205 ms
6,160 KB
testcase_08 AC 150 ms
5,976 KB
testcase_09 AC 209 ms
5,980 KB
testcase_10 AC 165 ms
6,220 KB
testcase_11 AC 153 ms
6,224 KB
testcase_12 AC 178 ms
6,220 KB
testcase_13 AC 166 ms
6,224 KB
testcase_14 AC 159 ms
6,160 KB
testcase_15 AC 158 ms
6,160 KB
testcase_16 AC 159 ms
6,220 KB
testcase_17 AC 166 ms
6,032 KB
testcase_18 AC 140 ms
6,100 KB
testcase_19 AC 210 ms
6,288 KB
testcase_20 AC 198 ms
6,084 KB
testcase_21 AC 211 ms
6,036 KB
testcase_22 AC 211 ms
5,988 KB
testcase_23 AC 216 ms
5,984 KB
testcase_24 AC 214 ms
6,216 KB
testcase_25 AC 218 ms
6,160 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