結果

問題 No.1140 EXPotentiaLLL!
ユーザー marroncastlemarroncastle
提出日時 2020-07-31 21:29:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 471 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 132,344 KB
最終ジャッジ日時 2023-09-20 21:41:37
合計ジャッジ時間 8,995 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 576 ms
131,640 KB
testcase_01 AC 599 ms
131,488 KB
testcase_02 WA -
testcase_03 AC 544 ms
129,644 KB
testcase_04 AC 501 ms
126,352 KB
testcase_05 AC 577 ms
132,344 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 343 ms
115,488 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 355 ms
114,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def sieve(n):
  is_prime = [True for _ in range(n+1)]
  is_prime[0] = False
  for i in range(2, n+1):
    if is_prime[i-1]:
      j = 2 * i
      while j <= n:
        is_prime[j-1] = False
        j += i
  return is_prime
def solve():
  input = sys.stdin.readline
  is_prime = sieve(5*10**6)
  T = int(input())
  ans = [-1]*T
  for i in range(T):
    A,P = map(int, input().split())
    if is_prime[P-1]:
      ans[i] = 1
  return ans
print(*solve(),sep='\n')
0