結果

問題 No.1140 EXPotentiaLLL!
ユーザー c-yanc-yan
提出日時 2020-08-02 00:13:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 1,933 ms
コンパイル使用メモリ 86,692 KB
実行使用メモリ 160,908 KB
最終ジャッジ日時 2023-09-22 21:19:35
合計ジャッジ時間 10,468 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 510 ms
155,228 KB
testcase_01 AC 507 ms
155,184 KB
testcase_02 AC 495 ms
160,908 KB
testcase_03 AC 448 ms
142,804 KB
testcase_04 AC 403 ms
134,152 KB
testcase_05 AC 510 ms
153,220 KB
testcase_06 AC 496 ms
148,428 KB
testcase_07 AC 546 ms
155,268 KB
testcase_08 AC 246 ms
115,080 KB
testcase_09 AC 239 ms
115,084 KB
testcase_10 AC 235 ms
114,896 KB
testcase_11 AC 242 ms
115,088 KB
testcase_12 AC 240 ms
115,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, int(n ** 0.5) + 1):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


readline = open(0).readline

prime_table = make_prime_table(5 * 10 ** 6)

T = int(readline())
result = []
for _ in range(T):
    A, P = map(int, readline().split())
    if prime_table[P] != P:
        result.append(-1)
    else:
        if A % P == 0:
            result.append(0)
        else:
            result.append(1)
print(*result, sep='\n')
0