結果
問題 | No.3030 ミラー・ラビン素数判定法のテスト |
ユーザー |
|
提出日時 | 2020-12-01 23:46:14 |
言語 | PyPy3 (7.3.11) |
結果 |
RE
|
実行時間 | - |
コード長 | 612 bytes |
コンパイル時間 | 406 ms |
コンパイル使用メモリ | 87,004 KB |
実行使用メモリ | 80,380 KB |
最終ジャッジ日時 | 2023-08-11 23:29:36 |
合計ジャッジ時間 | 3,362 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 68 ms
71,324 KB |
testcase_01 | AC | 66 ms
71,316 KB |
testcase_02 | AC | 67 ms
71,208 KB |
testcase_03 | AC | 73 ms
71,216 KB |
testcase_04 | RE | - |
testcase_05 | AC | 364 ms
77,984 KB |
testcase_06 | AC | 220 ms
78,552 KB |
testcase_07 | AC | 221 ms
78,248 KB |
testcase_08 | AC | 221 ms
78,064 KB |
testcase_09 | AC | 510 ms
78,456 KB |
ソースコード
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)))