結果

問題 No.1287 えぬけー
ユーザー どららどらら
提出日時 2020-11-13 22:30:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 1,367 ms
コンパイル使用メモリ 165,956 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 03:29:15
合計ジャッジ時間 3,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll extgcd(ll a, ll b, ll &x, ll &y){
  ll d = a;
  if(b!=0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll mod_inverse(ll a, ll m){
  ll x, y;
  extgcd(a, m, x, y);
  return (m+x%m)%m;
}

ll mod_pow(ll x, ll n, ll mod){
  if(n==0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if(n & 1) res = res * x % mod;
  return res;
}

int main(){
  int T;
  cin >> T;

  rep(i,T){
    ll X, K;
    cin >> X >> K;

    ll KK = mod_inverse(K, 1000000006);
    cout << mod_pow(X, KK, 1000000007) << endl;
  }
  
  return 0;
}
0