結果

問題 No.1287 えぬけー
ユーザー 👑 NachiaNachia
提出日時 2020-11-13 21:54:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 166,032 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 02:49:31
合計ジャッジ時間 3,552 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

LL ExtGcd(LL a, LL b, LL & x, LL & y) {
	if (b == 0) { x = 1; y = 0; return a; }
	LL g = ExtGcd(b, a % b, y, x);
	y -= a / b * x;
	return g;
}

ULL inv1000000006(ULL a) {
	LL M = 1000000006;
	LL x, y;
	ExtGcd((LL)a, 1000000006, x, y);
	x = ((x % M) + M) % M;
	return (ULL)x;
}

ULL powm(ULL a, ULL i, ULL M) {
	if (i == 0) return 1;
	ULL r = powm(a * a % M, i >> 1, M);
	if (i & 1) r = r * a % M;
	return r;
}


void loop() {
	ULL x, k; cin >> x >> k;
	ULL n = powm(x, inv1000000006(k), 1000000007);
	cout << n << endl;
}

int main() {
	int T; cin >> T;
	while (T--) loop();
	return 0;
}
0