結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 rin204rin204
提出日時 2020-08-13 07:03:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 462 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,484 KB
実行使用メモリ 116,368 KB
最終ジャッジ日時 2024-04-18 01:13:22
合計ジャッジ時間 6,790 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 462 ms
116,096 KB
testcase_01 AC 461 ms
115,968 KB
testcase_02 AC 441 ms
116,368 KB
testcase_03 AC 403 ms
116,068 KB
testcase_04 AC 378 ms
115,488 KB
testcase_05 AC 445 ms
116,224 KB
testcase_06 AC 432 ms
115,788 KB
testcase_07 AC 456 ms
116,224 KB
testcase_08 AC 209 ms
98,432 KB
testcase_09 AC 209 ms
98,688 KB
testcase_10 AC 216 ms
98,816 KB
testcase_11 AC 216 ms
98,816 KB
testcase_12 AC 217 ms
98,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

p_max = 5 * (10 ** 6)
prime = [True for _ in range(p_max + 1)]
prime[0] = False
prime[1] = False
p_max = 5 * (10 ** 6)
for i in range(2, int(p_max ** 0.5) + 1):
    if not prime[i]:
        continue
    for j in range(2 * i, p_max + 1, i):
        prime[j] = False

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