結果

問題 No.1140 EXPotentiaLLL!
ユーザー rlangevinrlangevin
提出日時 2023-01-02 02:20:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 760 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 175,444 KB
最終ジャッジ日時 2023-08-17 23:16:01
合計ジャッジ時間 12,027 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 678 ms
175,160 KB
testcase_01 AC 644 ms
175,188 KB
testcase_02 AC 626 ms
175,152 KB
testcase_03 AC 636 ms
175,100 KB
testcase_04 AC 570 ms
175,372 KB
testcase_05 AC 685 ms
175,292 KB
testcase_06 AC 655 ms
175,444 KB
testcase_07 AC 760 ms
175,432 KB
testcase_08 AC 400 ms
174,064 KB
testcase_09 AC 403 ms
173,964 KB
testcase_10 AC 399 ms
173,728 KB
testcase_11 AC 395 ms
173,812 KB
testcase_12 AC 406 ms
173,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline
from math import *

def Sieve(n):
    lst = [True] * (n + 1)
    S = set()
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.add(i)
    return S


T = int(readline())
S = Sieve(5050505)
for _ in range(T):
    A, P = map(int, readline().split())
    if P not in S:
        print(-1)
    else:
        if A % P:
            print(1)
        else:
            print(0)
0