結果

問題 No.1140 EXPotentiaLLL!
コンテスト
ユーザー cologne
提出日時 2025-12-08 15:41:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 569 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 471 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 117,496 KB
最終ジャッジ日時 2025-12-08 15:42:03
合計ジャッジ時間 9,189 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
import math


def input(): return sys.stdin.readline().rstrip('\n')


def main():
    s = [True] * (5 * 10 ** 6 + 1)
    s[0] = s[1] = False
    for i in range(2, math.isqrt(len(s) - 1) + 1):
        if s[i]:
            for j in range(i * i, len(s) - 1, i):
                s[j] = False

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


if __name__ == '__main__':
    ret = main()
    if ret is not None:
        print(ret)
0