結果

問題 No.1140 EXPotentiaLLL!
ユーザー toyuzuko
提出日時 2020-08-09 12:20:06
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,959 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 50,048 KB
最終ジャッジ日時 2024-10-04 08:53:55
合計ジャッジ時間 24,058 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def sieve(n):
    res = [True for _ in range(n + 1)]
    res[0] = False
    res[1] = False
    i = 2
    while i * i <= n:
        if res[i]:
            for j in range(i * 2, n + 1, i):
                res[j] = False
        i += 1
    return res

T = int(input())
S = sieve(5 * 10**6)

for _ in range(T):
    a, p = map(int, input().split())
    if not S[p]:
        print(-1)
    else:
        if a % p == 0:
            print(0)
        else:
            print(1)
0