結果

問題 No.1206 OR, OR, OR......
ユーザー boutarouboutarou
提出日時 2020-08-30 13:21:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 1,837 ms
コンパイル使用メモリ 164,788 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-09 11:43:23
合計ジャッジ時間 2,252 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll MOD = 998244353;

long long mod_pow(long long n, long long p, long long m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        long long t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    ll res1 = mod_pow(mod_pow(2, n, MOD), k, MOD);
    ll res2 = mod_pow(mod_pow(2, n - 1, MOD), k, MOD);
    ll res = (res1 - res2) % MOD;
    if (res < 0) res += MOD;
    cout << res * n % MOD << endl;
}
int main() {
    int t;
    cin >> t;
    rep(i, t) {
        solve();
    }
    return 0;
}
0