結果
| 問題 |
No.1287 えぬけー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-14 00:36:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 2,000 ms |
| コード長 | 718 bytes |
| コンパイル時間 | 1,783 ms |
| コンパイル使用メモリ | 166,164 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 22:29:10 |
| 合計ジャッジ時間 | 2,662 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 |
ソースコード
#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;
}