結果

問題 No.1140 EXPotentiaLLL!
ユーザー koba-e964koba-e964
提出日時 2021-09-18 11:32:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 565 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 117,260 KB
最終ジャッジ日時 2023-09-12 21:13:10
合計ジャッジ時間 8,685 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 518 ms
117,012 KB
testcase_01 AC 520 ms
116,904 KB
testcase_02 AC 467 ms
116,752 KB
testcase_03 AC 496 ms
116,196 KB
testcase_04 AC 425 ms
116,224 KB
testcase_05 AC 511 ms
116,280 KB
testcase_06 AC 481 ms
116,396 KB
testcase_07 AC 565 ms
117,260 KB
testcase_08 AC 287 ms
114,276 KB
testcase_09 AC 255 ms
114,428 KB
testcase_10 AC 257 ms
114,308 KB
testcase_11 AC 255 ms
114,280 KB
testcase_12 AC 259 ms
114,236 KB
権限があれば一括ダウンロードができます

ソースコード

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