結果
| 問題 |
No.1287 えぬけー
|
| コンテスト | |
| ユーザー |
ocvret_
|
| 提出日時 | 2020-11-14 01:13:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 270 ms / 2,000 ms |
| コード長 | 770 bytes |
| コンパイル時間 | 1,800 ms |
| コンパイル使用メモリ | 167,044 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-22 22:34:10 |
| 合計ジャッジ時間 | 3,854 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 |
ソースコード
#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
ll ext_gcd(ll a,ll b,ll &x,ll &y){
if(b == 0){
x = 1,y = 0;
return a;
}
ll d = ext_gcd(b,a%b,x,y);
ll z = x-(a/b)*y;
x = y,y = z;
return d;
}
ll modpow(ll n,ll r){
if(r < 0)return 1;
ll res = 1;
while(r){
if(r & 1)res = res*n%MOD;
n = n*n%MOD;
r >>= 1;
}
return res;
}
int main(){
int T;
cin >> T;
while(T--){
ll x,k;cin >> x >> k;
ll a,b;
ext_gcd(MOD-1,k,a,b);
cout << modpow(x,b+MOD-1) << "\n";
}
return 0;
}
ocvret_