結果

問題 No.2467 Sum of Product of Binomial Coefficients
ユーザー だれ
提出日時 2023-09-06 03:37:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 66,548 KB
最終ジャッジ日時 2025-02-16 18:58:04
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
using i64 = long long;

const i64 mod = 998244353;

i64 modpow(i64 a, i64 b) {
    i64 res = 1;
    while (b) {
        if (b & 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        i64 n, k;
        cin >> n >> k;
        i64 ans = 0;
        for (int i = 1; i <= k; i++) {
            ans = (ans + modpow(i + 1, n)) % mod;
        }
        cout << ans << "\n";
    }
}
0