結果
問題 | No.3030 ミラー・ラビン素数判定法のテスト |
ユーザー |
![]() |
提出日時 | 2021-01-18 20:32:08 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 573 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 77,520 KB |
最終ジャッジ日時 | 2024-11-18 19:15:38 |
合計ジャッジ時間 | 1,577 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
ソースコード
def is_prime(n): if n == 2: return True if n == 1 or n & 1 == 0: return False d = n - 1 L = [2, 325, 9375, 28178, 450775, 9780504, 1795265022] for a in L: if n <= a: return True a = pow(a, d, n) if a == 1: continue r = 1 while a != n - 1: if r == s: return False a = a * a % n r += 1 return True def solve(): x = int(input()) print(x, int(is_prime(x))) n = int(input()) for i in range(n): solve()