結果

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

ソースコード

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), 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