結果
問題 | No.3030 ミラー・ラビン素数判定法のテスト |
ユーザー | chankei271828 |
提出日時 | 2024-02-18 10:51:09 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 608 ms / 9,973 ms |
コード長 | 569 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 78,820 KB |
最終ジャッジ日時 | 2024-02-18 10:51:13 |
合計ジャッジ時間 | 3,619 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
54,100 KB |
testcase_01 | AC | 37 ms
54,100 KB |
testcase_02 | AC | 39 ms
56,148 KB |
testcase_03 | AC | 39 ms
56,148 KB |
testcase_04 | AC | 411 ms
77,692 KB |
testcase_05 | AC | 406 ms
77,700 KB |
testcase_06 | AC | 220 ms
77,696 KB |
testcase_07 | AC | 226 ms
77,940 KB |
testcase_08 | AC | 235 ms
77,808 KB |
testcase_09 | AC | 608 ms
78,820 KB |
ソースコード
#これを使いましょう(泣) import random def is_prime(n): if n == 2: return True if n == 1 or n & 1 == 0: return False d = (n - 1) >> 1 while d & 1 == 0: d >>= 1 for k in range(10): a = random.randint(1, n - 1) t = d y = pow(a, t, n) while t != n - 1 and y != 1 and y != n - 1: y = (y * y) % n t <<= 1 if y != n - 1 and t & 1 == 0: return False return True N=int(input()) for _ in range(N): x=int(input()) print(x,int(is_prime(x)))