結果

問題 No.1140 EXPotentiaLLL!
ユーザー H3PO4H3PO4
提出日時 2020-07-31 21:36:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,223 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 74,456 KB
最終ジャッジ日時 2023-09-20 22:09:05
合計ジャッジ時間 14,790 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,124 ms
74,040 KB
testcase_01 AC 1,082 ms
74,316 KB
testcase_02 AC 1,152 ms
74,424 KB
testcase_03 AC 951 ms
74,352 KB
testcase_04 AC 776 ms
74,300 KB
testcase_05 AC 1,077 ms
74,320 KB
testcase_06 AC 1,034 ms
74,244 KB
testcase_07 AC 1,223 ms
74,248 KB
testcase_08 AC 238 ms
74,264 KB
testcase_09 AC 243 ms
74,180 KB
testcase_10 AC 247 ms
74,456 KB
testcase_11 AC 244 ms
74,268 KB
testcase_12 AC 239 ms
74,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import sys

input = sys.stdin.readline


def primes_np(n):
    is_prime = np.ones(n + 1, dtype=bool)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        is_prime[i * 2:n + 1:i] = False
    return np.where(is_prime)[0].tolist()


PR = set(primes_np(5 * 10 ** 6))
T = int(input())
for _ in range(T):
    A, P = map(int, input().split())
    if P in PR:
        print(1 if A % P else 0)
    else:
        print(-1)
0