結果

問題 No.1140 EXPotentiaLLL!
ユーザー rin204
提出日時 2020-08-13 07:03:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 508 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 60,416 KB
最終ジャッジ日時 2024-10-09 18:56:45
合計ジャッジ時間 7,294 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 2 -- * 10
権限があれば一括ダウンロードができます

ソースコード

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