結果

問題 No.308 素数は通れません
ユーザー tjake
提出日時 2015-12-01 22:24:04
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 393 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-09-14 06:42:16
合計ジャッジ時間 4,436 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 86 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

from random import randint, seed
seed()

n = input()

m = {3: [4], 5: [6], 7: [8,9,10,15,16,22], 11: [12], 13: [14], 19: [20,21], 23: [24,25]}

def fermat(k):
    for t in xrange(1000):
        a = randint(2, k-1)
        if pow(a, k-1, k)!=1:
            return 0
    return 1

for w in m:
    if n in m[w]:
        print w
        exit(0)

if not fermat(n-8):
    print 8
else:
    print 14
0