結果

問題 No.1287 えぬけー
ユーザー ygd.ygd.
提出日時 2020-11-14 20:15:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 547 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 78,608 KB
最終ジャッジ日時 2023-09-30 06:33:52
合計ジャッジ時間 3,738 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,160 KB
testcase_01 AC 77 ms
71,208 KB
testcase_02 AC 76 ms
71,280 KB
testcase_03 AC 76 ms
70,944 KB
testcase_04 AC 75 ms
71,088 KB
testcase_05 AC 547 ms
78,608 KB
testcase_06 AC 523 ms
78,176 KB
testcase_07 AC 538 ms
77,964 KB
testcase_08 AC 508 ms
78,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Ext_gcd(a,b): #GCD,p,qを返す。
    if b == 0:
        return (a,1,0)
    g,y,x = Ext_gcd(b,a%b)
    y -= a//b*x
    return (g,x,y)

p = pow(10,9)+7
T = int(input())
for _ in range(T):
    X,K = map(int,input().split())
    g,x,y = Ext_gcd(1-p,K)
    y %= p-1
    ans = pow(X,y,p)
    print(ans)
0