結果

問題 No.1287 えぬけー
ユーザー ocvret_ocvret_
提出日時 2020-11-14 01:13:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 1,514 ms
コンパイル使用メモリ 165,608 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 04:37:25
合計ジャッジ時間 3,038 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0