結果

問題 No.1140 EXPotentiaLLL!
ユーザー terasaterasa
提出日時 2022-09-19 10:43:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,113 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 145,032 KB
最終ジャッジ日時 2023-08-23 18:48:10
合計ジャッジ時間 10,668 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 637 ms
144,660 KB
testcase_01 AC 651 ms
144,304 KB
testcase_02 WA -
testcase_03 AC 599 ms
144,496 KB
testcase_04 AC 560 ms
144,784 KB
testcase_05 AC 643 ms
144,764 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 360 ms
143,004 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 362 ms
143,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
# import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import string
import functools
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
# pypyjit.set_param('max_unroll_recursion=-1')


def readints(): return map(int, input().split())
def readlist(): return list(map(int, input().split()))
def readstr(): return input()[:-1]


class PrimeTable:
    def __init__(self, N):
        self.is_prime = [True] * (N + 1)

        self.is_prime[0] = False
        self.is_prime[1] = False
        for i in range(2, N + 1):
            if i * i > N:
                break
            if self.is_prime[i] is False:
                continue
            for j in range(2, N + 1):
                if i * j > N:
                    break
                self.is_prime[i * j] = False

        self.primes = [n for n in range(2, N + 1) if self.is_prime[n]]


L = 5 * 10 ** 6
is_prime = PrimeTable(L).is_prime

T = int(input())
for _ in range(T):
    a, p = readints()
    if is_prime[p]:
        print(1 if a != p else 0)
    else:
        print(-1)
0