結果
問題 | No.3030 ミラー・ラビン素数判定法のテスト |
ユーザー | aqua_tenhou |
提出日時 | 2021-01-18 20:34:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 640 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 77,056 KB |
最終ジャッジ日時 | 2024-04-29 14:50:44 |
合計ジャッジ時間 | 2,512 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 40 ms
51,712 KB |
testcase_02 | AC | 41 ms
52,224 KB |
testcase_03 | AC | 41 ms
52,224 KB |
testcase_04 | AC | 290 ms
76,672 KB |
testcase_05 | AC | 276 ms
76,544 KB |
testcase_06 | AC | 199 ms
77,056 KB |
testcase_07 | AC | 191 ms
76,544 KB |
testcase_08 | AC | 205 ms
76,416 KB |
testcase_09 | AC | 403 ms
76,416 KB |
ソースコード
def is_prime(n): if n == 2: return True if n == 1 or n & 1 == 0: return False d = n - 1 s = 0 while d % 2 == 0: d >>= 1 s += 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()