結果

問題 No.1140 EXPotentiaLLL!
ユーザー c-yanc-yan
提出日時 2020-08-03 05:01:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,695 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 220,376 KB
最終ジャッジ日時 2023-09-29 13:16:49
合計ジャッジ時間 20,170 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,576 ms
220,376 KB
testcase_01 AC 1,566 ms
220,220 KB
testcase_02 AC 1,573 ms
220,324 KB
testcase_03 AC 1,461 ms
217,004 KB
testcase_04 AC 1,339 ms
214,176 KB
testcase_05 AC 1,558 ms
219,820 KB
testcase_06 AC 1,604 ms
218,936 KB
testcase_07 AC 1,695 ms
220,312 KB
testcase_08 AC 887 ms
203,788 KB
testcase_09 AC 878 ms
203,768 KB
testcase_10 AC 907 ms
203,792 KB
testcase_11 AC 884 ms
203,796 KB
testcase_12 AC 894 ms
203,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            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