結果

問題 No.1287 えぬけー
ユーザー kotatsugamekotatsugame
提出日時 2020-11-13 21:45:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 65,528 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 02:41:40
合計ジャッジ時間 2,370 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 242 ms
4,380 KB
testcase_06 AC 248 ms
4,380 KB
testcase_07 AC 254 ms
4,376 KB
testcase_08 AC 238 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
a.cpp:5:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]

ソースコード

diff #

#line 1 "a.cpp"
#include<iostream>
using namespace std;
#line 1 "/home/kotatsugame/library/math/extgcd.cpp"
template<typename T>
T extgcd(T a,T b,T&x,T&y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	T q=a/b;
	T g=extgcd(b,a-q*b,y,x);
	y-=q*x;
	return g;
}
#line 4 "a.cpp"
int T;
main()
{
	cin>>T;
	for(;T--;)
	{
		long X,K;cin>>X>>K;
		long x,y;
		long m=1e9+6;
		extgcd(m,K,x,y);
		y%=m;
		if(y<m)y+=m;
		m++;
		long r=1;
		while(y)
		{
			if(y%2)r=r*X%m;
			y>>=1;
			X=X*X%m;
		}
		cout<<r<<endl;
	}
}
0