結果

問題 No.1140 EXPotentiaLLL!
ユーザー tyawanmusityawanmusi
提出日時 2020-07-31 22:01:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 385 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 86,568 KB
実行使用メモリ 82,532 KB
最終ジャッジ日時 2023-09-20 23:19:55
合計ジャッジ時間 10,833 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,160 ms
80,576 KB
testcase_01 AC 589 ms
78,532 KB
testcase_02 WA -
testcase_03 AC 539 ms
79,140 KB
testcase_04 AC 441 ms
78,896 KB
testcase_05 AC 628 ms
79,536 KB
testcase_06 RE -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def isPrimeMR(n):
  d = n - 1
  d = d // (d & -d)
  L = [2, 3, 61]
  for a in L:
    t = d
    y = pow(a, t, n)
    if y == 1: continue
    while y != n - 1:
      y = (y * y) % n
      if y == 1 or t == n - 1: return 0
      t <<= 1
  return 1
for _ in range(int(input())):
  a,p=map(int,input().split())
  if isPrimeMR(p):print(1)
  else:print(-1)
0