結果

問題 No.2467 Sum of Product of Binomial Coefficients
ユーザー だれだれ
提出日時 2023-09-06 03:37:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 68,256 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 00:41:42
合計ジャッジ時間 1,840 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 31 ms
4,376 KB
testcase_02 AC 32 ms
4,376 KB
testcase_03 AC 32 ms
4,376 KB
testcase_04 AC 32 ms
4,376 KB
testcase_05 AC 214 ms
4,380 KB
testcase_06 AC 36 ms
4,380 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 27 ms
4,380 KB
testcase_09 AC 68 ms
4,380 KB
testcase_10 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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