結果

問題 No.1287 えぬけー
ユーザー lorent_kyoprolorent_kyopro
提出日時 2020-11-14 00:16:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 201,500 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 04:27:57
合計ジャッジ時間 3,089 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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