結果

問題 No.1287 えぬけー
ユーザー 沙耶花沙耶花
提出日時 2020-11-13 22:14:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 1,918 ms
コンパイル使用メモリ 203,936 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 03:07:02
合計ジャッジ時間 3,895 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/math>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000005
#define modulo 1000000007



int main(){

	int T;
	cin>>T;
	
	rep(_,T){
		int X,K;
		cin>>X>>K;
		
		vector<long long> num(30);
		num[0] = X;
		
		for(int i=1;i<30;i++){
			num[i] = num[i-1];
			num[i] *= num[i-1];
			num[i] %= modulo;
		}
		
		long long x = inv_mod(K,modulo-1);
		
		long long ans = 1;
		
		rep(i,30){
			if((x>>i)&1)ans *= num[i];
			ans %= modulo;
		}
		
		cout<<ans<<endl;
		
	}

	return 0;
}
0