結果

問題 No.1140 EXPotentiaLLL!
ユーザー ayaoniayaoni
提出日時 2021-04-20 13:17:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,167 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 89,296 KB
最終ジャッジ日時 2023-09-17 08:39:39
合計ジャッジ時間 5,443 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 343 ms
88,608 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 91 ms
87,164 KB
testcase_09 AC 94 ms
87,292 KB
testcase_10 AC 92 ms
87,184 KB
testcase_11 AC 92 ms
87,400 KB
testcase_12 AC 96 ms
87,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


def sieve_of_eratosthenes(n):  # n以下の素数の全列挙
    prime_list = []
    is_prime = [1]*(n+1)  # A[i] = iが素数なら1,その他は0
    is_prime[0] = is_prime[1] = 0
    for i in range(2,int(n**.5)+1):
        if is_prime[i]:
            prime_list.append(i)
            for j in range(i**2,n+1,i):
                is_prime[j] = 0
    for i in range(int(n**.5)+1,n+1):
        if is_prime[i] == 1:
            prime_list.append(i)
    return prime_list


prime_list = sieve_of_eratosthenes(5*10**5)
prime_list = set(prime_list)

T = I()
for _ in range(T):
    A,P = MI()
    if P not in prime_list:
        print(-1)
        continue

    if A % P == 0:
        print(0)
    else:
        print(1)
0