結果

問題 No.1140 EXPotentiaLLL!
ユーザー koba-e964koba-e964
提出日時 2021-09-18 11:26:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,670 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 117,344 KB
最終ジャッジ日時 2023-09-12 21:04:58
合計ジャッジ時間 17,430 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,522 ms
117,104 KB
testcase_01 AC 1,618 ms
117,300 KB
testcase_02 AC 1,502 ms
116,984 KB
testcase_03 AC 1,306 ms
117,244 KB
testcase_04 AC 1,120 ms
117,084 KB
testcase_05 AC 1,519 ms
117,344 KB
testcase_06 AC 1,462 ms
117,144 KB
testcase_07 AC 1,670 ms
117,272 KB
testcase_08 AC 359 ms
115,512 KB
testcase_09 AC 367 ms
115,520 KB
testcase_10 AC 383 ms
115,528 KB
testcase_11 AC 372 ms
115,520 KB
testcase_12 AC 369 ms
115,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import sys
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, n):
        if not a[i]:
            continue
        for j in range(2, (n - 1) // i + 1):
            a[i * j] = False
    return a


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