結果
問題 | No.308 素数は通れません |
ユーザー |
|
提出日時 | 2022-04-23 00:29:27 |
言語 | PyPy2 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 411 bytes |
コンパイル時間 | 1,310 ms |
コンパイル使用メモリ | 76,916 KB |
実行使用メモリ | 94,328 KB |
最終ジャッジ日時 | 2024-06-24 06:05:57 |
合計ジャッジ時間 | 21,366 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 106 WA * 1 |
ソースコード
from random import randint 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 (n%8!=1 and not fermat(n-1)) or not fermat(n-8): print 8 else: print 14