結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void extgcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1, y = 0;
        return;
    }
    extgcd(b, a % b, y, x);
    y -= a / b * x;
}

constexpr int mod = 1000000007;

void solve() {
    int x, k;
    cin >> x >> k;
    int a, b;
    extgcd(k, mod - 1, a, b);
    a += mod - 1;
    cout << mint(x).pow(a).val() << '\n';
}

int main() {
    int t;
    cin >> t;
    while (t--) solve();
}
0