結果

問題 No.1140 EXPotentiaLLL!
ユーザー koba-e964
提出日時 2021-09-18 11:32:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 505 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 116,236 KB
最終ジャッジ日時 2024-06-30 08:45:11
合計ジャッジ時間 7,489 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import sys
import math
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

def eratosthenes(n):
    a = [True] * n
    a[0] = False
    a[1] = False
    for i in range(2, math.ceil(math.sqrt(n - 1))):
        if not a[i]:
            continue
        for j in range(2, (n - 1) // i + 1):
            a[i * j] = False
    return a


t = int(readline())
pr = eratosthenes(5000001)
for _ in range(t):
    a, p = map(int, readline().split())
    if pr[p]:
        print(0 if a % p == 0 else 1)
    else:
        print(-1)
0