結果

問題 No.1140 EXPotentiaLLL!
ユーザー FromBooskaFromBooska
提出日時 2023-02-23 21:02:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,669 ms / 2,000 ms
コード長 476 bytes
コンパイル時間 987 ms
コンパイル使用メモリ 86,660 KB
実行使用メモリ 170,920 KB
最終ジャッジ日時 2023-09-30 20:59:31
合計ジャッジ時間 18,676 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,547 ms
170,696 KB
testcase_01 AC 1,579 ms
170,920 KB
testcase_02 AC 1,545 ms
170,796 KB
testcase_03 AC 1,345 ms
170,576 KB
testcase_04 AC 1,101 ms
170,740 KB
testcase_05 AC 1,545 ms
170,768 KB
testcase_06 AC 1,501 ms
170,920 KB
testcase_07 AC 1,669 ms
170,640 KB
testcase_08 AC 390 ms
169,956 KB
testcase_09 AC 376 ms
170,144 KB
testcase_10 AC 355 ms
169,964 KB
testcase_11 AC 410 ms
170,372 KB
testcase_12 AC 380 ms
170,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = 5*10**6+2
is_prime = [1]*(n + 1)
is_prime[0] = 0  
is_prime[1] = 0
for p in range(2, n + 1):
    if is_prime[p]:
        for q in range(2*p, n + 1, p):
            is_prime[q] = 0

primes = set()
for i in range(n):
    if is_prime[i] == 1:
        primes.add(i)
        
T = int(input())
for t in range(T):
    A, P = map(int, input().split())
    if P not in primes:
        print(-1)
    else:
        if A%P == 0:
            print(0)
        else:
            print(1)
0