結果

問題 No.1287 えぬけー
ユーザー shinchan
提出日時 2020-11-14 01:36:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 192,304 KB
最終ジャッジ日時 2025-01-16 00:21:37
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll mod;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    cin >> t;
    while(t--){
        ll x, k;
        cin >> x >> k;
        mod = 1000000006;
        k = modpow(k, mod / 2 - 2);
        mod++;
        cout << modpow(x, k) << endl;
    }
    return 0;
}


0