結果
問題 | No.8030 ミラー・ラビン素数判定法のテスト |
ユーザー |
|
提出日時 | 2020-12-01 23:46:14 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 612 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 77,872 KB |
最終ジャッジ日時 | 2024-11-18 18:58:46 |
合計ジャッジ時間 | 2,596 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 RE * 1 |
ソースコード
def isPrimeMR(n): if n in {2, 3, 5, 7, 11, 13, 17}: return True d = n - 1 d = d // (d & -d) L = ( [2, 7, 61] if n < 1 << 32 else [2, 3, 5, 7, 11, 13, 17] if n < 1 << 48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] ) 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 False t <<= 1 return True for i in range(int(input())): x = int(input()) print(x, int(isPrimeMR(x)))