結果

問題 No.1140 EXPotentiaLLL!
ユーザー qibqib
提出日時 2022-11-19 19:23:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 903 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 163,748 KB
最終ジャッジ日時 2023-10-21 00:31:35
合計ジャッジ時間 11,698 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 851 ms
155,516 KB
testcase_01 AC 817 ms
155,436 KB
testcase_02 AC 837 ms
163,748 KB
testcase_03 AC 727 ms
145,728 KB
testcase_04 AC 676 ms
137,152 KB
testcase_05 AC 818 ms
155,552 KB
testcase_06 AC 773 ms
151,136 KB
testcase_07 AC 903 ms
158,700 KB
testcase_08 AC 399 ms
114,732 KB
testcase_09 AC 405 ms
114,736 KB
testcase_10 AC 411 ms
114,728 KB
testcase_11 AC 415 ms
114,736 KB
testcase_12 AC 417 ms
114,664 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

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

print(*ans, sep='\n')
0