結果

問題 No.2467 Sum of Product of Binomial Coefficients
ユーザー Yerin JungYerin Jung
提出日時 2023-09-23 21:16:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,056 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 165,056 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-23 21:16:24
合計ジャッジ時間 2,956 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 27 ms
4,376 KB
testcase_02 AC 28 ms
4,380 KB
testcase_03 AC 27 ms
4,380 KB
testcase_04 AC 27 ms
4,376 KB
testcase_05 AC 47 ms
4,380 KB
testcase_06 AC 18 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 24 ms
4,376 KB
testcase_09 AC 33 ms
4,380 KB
testcase_10 AC 7 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair < int , int > pii ;
typedef vector < int > vi ;
#define fi first
#define se second
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

const int MOD = 998244353 ;

ll fastpow ( ll x , ll pw ) {
    ll ret = 1 ;
    while ( pw > 0 ) {
        if ( ( pw % 2 ) == 0 ) {
            x = ( x * x ) % MOD ;
            pw /= 2 ;
        }
        else {
            ret = ( ret * x ) % MOD ;
            -- pw ;
        }
    }
    return ret ;
}

void solve ( ) {
    int n , k ;
    cin >> n >> k ;
    ll ans = 0 ;
    for ( int i = 2 ; i <= k + 1 ; ++ i ) {
        ans = ( ans + fastpow ( i , n ) ) % MOD ;
    }
    cout << ans << "\n" ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    int t = 1 ; cin >> t ;
    while ( t -- ) { solve ( ) ; }
    return 0 ;
}
0