結果

問題 No.2113 Distance Sequence 1.5
ユーザー zhtluozhtluo
提出日時 2022-10-28 22:06:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 2,877 ms
コンパイル使用メモリ 198,080 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-20 05:05:38
合計ジャッジ時間 4,122 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

const long long MOD = 998244353;
long long N, M, K;

long long pow(long long s, long long t) {
    long long ret = 1;
    s %= MOD;
    while (t) {
        if (t & 1) ret = ret * s % MOD;
        s = s * s % MOD;
        t >>= 1;
    }
    return ret;
}

int main() {
    scanf("%lld%lld%lld", &N, &M, &K);
    if (M - K + 1 < 0) {
        puts ("0");
        return 0;
    }
    long long ans = ((M - K + 1) % MOD * (pow(K, 2 * N) - pow(K - 1, 2 * N) + MOD) + pow(K - 1, 2 * N)) % MOD;
    printf("%lld\n", ans);
}
0