結果

問題 No.1140 EXPotentiaLLL!
ユーザー rlangevinrlangevin
提出日時 2023-01-02 02:20:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 667 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 174,464 KB
最終ジャッジ日時 2024-05-05 06:04:06
合計ジャッジ時間 9,669 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 605 ms
174,080 KB
testcase_01 AC 582 ms
173,824 KB
testcase_02 AC 576 ms
174,080 KB
testcase_03 AC 546 ms
174,336 KB
testcase_04 AC 487 ms
174,208 KB
testcase_05 AC 585 ms
174,208 KB
testcase_06 AC 570 ms
173,952 KB
testcase_07 AC 667 ms
174,464 KB
testcase_08 AC 339 ms
158,464 KB
testcase_09 AC 340 ms
158,592 KB
testcase_10 AC 312 ms
158,592 KB
testcase_11 AC 324 ms
158,592 KB
testcase_12 AC 343 ms
158,592 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