結果

問題 No.1287 えぬけー
ユーザー finefine
提出日時 2020-11-14 00:36:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 1,339 ms
コンパイル使用メモリ 163,888 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 04:32:25
合計ジャッジ時間 2,449 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 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,380 KB
testcase_05 AC 54 ms
4,380 KB
testcase_06 AC 53 ms
4,376 KB
testcase_07 AC 54 ms
4,380 KB
testcase_08 AC 50 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

constexpr ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        ll x, K;
        cin >> x >> K;
        if (x == 0) {
            cout << 0 << newl;
            continue;
        }
        constexpr ll hoge = 500000003 - 1;
        ll ans = modpow(x, modpow(K, hoge - 1, MOD - 1));
        cout << ans << newl;
    }

    return 0;
}
0