結果

問題 No.1140 EXPotentiaLLL!
ユーザー aaaaaaaaaa2230
提出日時 2020-08-05 23:47:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 302 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 117,976 KB
最終ジャッジ日時 2024-09-18 18:05:44
合計ジャッジ時間 17,222 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

MA = 5*10**6+1
s = [0]*(MA)

s[1] = 2
for i in range(2,MA):
    for j in range(i,MA,i):
        s[j] += 1
    

t = int(input())
for _ in range(t):
    a,p = map(int,input().split())
    if s[p] == 1:
        print(pow(a,p*(p+1)//2,p))
    else:
        print(-1)
0