結果

問題 No.1140 EXPotentiaLLL!
ユーザー lloyzlloyz
提出日時 2022-05-29 14:04:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 708 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 116,660 KB
最終ジャッジ日時 2023-10-20 23:47:09
合計ジャッジ時間 10,222 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 685 ms
116,476 KB
testcase_01 AC 682 ms
115,852 KB
testcase_02 AC 702 ms
116,660 KB
testcase_03 AC 642 ms
115,668 KB
testcase_04 AC 591 ms
115,356 KB
testcase_05 AC 668 ms
115,856 KB
testcase_06 AC 654 ms
115,748 KB
testcase_07 AC 708 ms
116,476 KB
testcase_08 AC 429 ms
114,544 KB
testcase_09 AC 442 ms
114,540 KB
testcase_10 AC 437 ms
114,540 KB
testcase_11 AC 437 ms
114,540 KB
testcase_12 AC 436 ms
114,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

IsPrime = [True for _ in range(5 * 10**6 + 1)]
IsPrime[0] = IsPrime[1] = False
for i in range(2, 5 * 10**6 + 1):
    if IsPrime[i]:
        for j in range(i + i, 5 * 10**6 + 1, i):
            IsPrime[j] = False

t = int(input())
for _ in range(t):
    a, p = map(int, input().split())
    if IsPrime[p]:
        if a % p == 0:
            print(0)
        else:
            print(1)
    else:
        print(-1)
0