結果

問題 No.1140 EXPotentiaLLL!
ユーザー titiatitia
提出日時 2020-07-31 21:40:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 647 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 87,316 KB
実行使用メモリ 196,228 KB
最終ジャッジ日時 2023-09-20 22:20:13
合計ジャッジ時間 8,863 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 608 ms
196,228 KB
testcase_01 AC 556 ms
195,768 KB
testcase_02 WA -
testcase_03 AC 520 ms
195,896 KB
testcase_04 AC 479 ms
196,092 KB
testcase_05 AC 559 ms
195,924 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 312 ms
194,872 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 317 ms
194,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def calc(A,P):
    ANS=1
    for i in range(1,P+1):
        ANS*=i
    return pow(A,ANS,P)

import math
x=5*10**6+10
L=math.floor(math.sqrt(x)) # 平方根を求める

Primelist=[i for i in range(x+1)]
Primelist[1]=0 # 1は素数でないので0にする.
 
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0

Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]
S=set(Primes)

T=int(input())
for tests in range(T):
    A,P=map(int,input().split())

    if P in S:
        print(1)
    else:
        print(-1)
    
    
0