結果
| 問題 |
No.8030 ミラー・ラビン素数判定法のテスト
|
| ユーザー |
akasia_midori
|
| 提出日時 | 2022-05-03 07:54:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 715 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 78,780 KB |
| 最終ジャッジ日時 | 2024-07-02 11:23:49 |
| 合計ジャッジ時間 | 3,224 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 6 |
ソースコード
def one_str():
return input()
def many_int():
return list(map(int, input().split()))
import random
def Miller_Rabin_test(num):
if num == 2:
return True
if num > 2 and num & 1 == 0:
return False
s, t = 0, num-1
while t & 1 == 0:
s, t = s+1, t >> 1
a = random.randint(1, num-1)
if pow(a, t, num) == 1:
return True
for i in range(0, s):
if pow(a, pow(2, i) * t, num) == num-1:
return True
return False
input_count = 0
N = int(input())
for i in range(N):
num = int(input())
if num == 1:
print(*[1,0])
else:
check = Miller_Rabin_test(num)
ch = 1 if check else 0
print(*[num, ch])
akasia_midori