結果
| 問題 | No.308 素数は通れません |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-01 02:17:43 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 412 bytes |
| 記録 | |
| コンパイル時間 | 299 ms |
| コンパイル使用メモリ | 77,752 KB |
| 最終ジャッジ日時 | 2025-12-03 18:07:09 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 55 WA * 1 TLE * 1 -- * 50 |
ソースコード
import random
def solve(x):
x=x-1
while x%2==0:
x>>=1
for l in range(0,30):
r=random.randint(1,x-1)
t=x
y=pow(r,t,x)
while t!=x-1 and y!=1 and y!=x-1:
y=(y*y)%x
t<<=1
if y!=x-1 and t&1==0:
return False
return True
a=[0,0,0,0,3,0,5,0,7,7,7,0,11,0,13,7,7,0,8,0,19,19,7,0,23,23]
x=input()
if x<26:print a[x]
else:print 14 if (x-1)%8==0 and x%2 and solve(x-8) else 8