結果

問題 No.1140 EXPotentiaLLL!
ユーザー qibqib
提出日時 2022-11-19 19:21:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,671 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 115,560 KB
最終ジャッジ日時 2023-10-21 00:30:30
合計ジャッジ時間 18,256 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,636 ms
115,492 KB
testcase_01 AC 1,590 ms
115,416 KB
testcase_02 AC 1,599 ms
115,512 KB
testcase_03 AC 1,362 ms
115,520 KB
testcase_04 AC 1,141 ms
115,500 KB
testcase_05 AC 1,540 ms
115,520 KB
testcase_06 AC 1,491 ms
115,524 KB
testcase_07 AC 1,671 ms
115,560 KB
testcase_08 AC 423 ms
114,736 KB
testcase_09 AC 464 ms
114,736 KB
testcase_10 AC 421 ms
114,736 KB
testcase_11 AC 424 ms
114,736 KB
testcase_12 AC 420 ms
114,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

t = int(input())

m = 5000000

prime = [True for _ in range(m + 1)]
prime[1] = False

for x in range(2, m + 1):
  if not prime[x]:
    continue
  prime[x] = True
  for y in range(2 * x, m + 1, x):
    prime[y] = False

for _ in range(t):
  a, p = map(int, input().split())
  if not prime[p]:
    print("-1")
  elif math.gcd(a, p) == 1:
    print("1")
  else:
    print("0")
0