結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
![]() |
提出日時 | 2020-07-31 21:58:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 505 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 81,884 KB |
実行使用メモリ | 80,728 KB |
最終ジャッジ日時 | 2024-07-06 17:58:50 |
合計ジャッジ時間 | 6,270 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 WA * 7 RE * 3 |
ソースコード
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()