結果

問題 No.1140 EXPotentiaLLL!
ユーザー tyawanmusityawanmusi
提出日時 2020-07-31 21:58:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 86,168 KB
最終ジャッジ日時 2023-09-20 23:12:06
合計ジャッジ時間 7,886 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 641 ms
81,736 KB
testcase_01 AC 607 ms
79,676 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 AC 90 ms
72,364 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  import sys
  input=sys.stdin.readline

  import random

  def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    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)

if __name__ == "__main__":
  main()
0