結果

問題 No.1140 EXPotentiaLLL!
ユーザー tyawanmusi
提出日時 2020-07-31 22:01:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 385 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 80,408 KB
最終ジャッジ日時 2024-07-06 18:05:39
合計ジャッジ時間 9,688 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 5 WA * 4 RE * 3
権限があれば一括ダウンロードができます

ソースコード

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