結果

問題 No.3030 ミラー・ラビン素数判定法のテスト
ユーザー hari64hari64
提出日時 2021-07-27 21:53:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 1,142 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 78,740 KB
最終ジャッジ日時 2023-10-01 01:33:30
合計ジャッジ時間 4,345 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
76,180 KB
testcase_01 AC 77 ms
76,360 KB
testcase_02 AC 78 ms
76,356 KB
testcase_03 AC 79 ms
76,200 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def enumerate_primes(n: int) -> list:
    """エラトステネスの篩 計算量O(NloglogN)
    https://mikan-alpha.hatenablog.com/entry/2020/07/29/210342"""
    assert n >= 1
    isp = [True] * (n+1 >> 1)
    for i in range(3, int(n**0.5)+1, 2):
        if isp[i >> 1]:
            isp[i*i >> 1::i] = [False] * int(((n-1 >> 1)-(i*i >> 1))//i+1)
    return [2]*int(n != 1) + [(i << 1)+1 for i in range(1, n+1 >> 1) if isp[i]]


primes = enumerate_primes(10**5)
n = int(input())
for i in range(n):
    x = int(input())
    print(x, int(x in primes))
0