結果

問題 No.1140 EXPotentiaLLL!
ユーザー stngstng
提出日時 2022-09-04 21:39:12
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 623 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 120,704 KB
最終ジャッジ日時 2024-04-29 21:10:12
合計ジャッジ時間 7,392 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 41 ms
52,352 KB
testcase_09 AC 41 ms
52,224 KB
testcase_10 AC 40 ms
51,968 KB
testcase_11 RE -
testcase_12 AC 42 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
t = int(input())
ap = [[int(i) for i in input().split()] for j in range(t)]

def sieve_of_eratosthenes(n):
    prime = [True for i in range(n+1)]
    prime[0] = False
    prime[1] = False

    sqrt_n = math.ceil(math.sqrt(n))
    for i in range(2, sqrt_n):
        if prime[i]:
            for j in range(2*i, n+1, i):
                prime[j] = False

    return prime

val = 5*10**1
pri = sieve_of_eratosthenes(val)

#print(kai)
#exit()
for i in range(t):
    a,p = ap[i]
    if pri[p] == True:
        if math.gcd(a,p) == 1:
            print(1)
        else:
            print(0)
    else:
        print(-1)
0