結果

問題 No.3030 ミラー・ラビン素数判定法のテスト
ユーザー aqua_tenhouaqua_tenhou
提出日時 2021-01-18 20:32:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-04-29 14:50:24
合計ジャッジ時間 1,655 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

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()

0