結果
問題 |
No.308 素数は通れません
|
ユーザー |
![]() |
提出日時 | 2015-12-01 00:25:47 |
言語 | Python2 (2.7.18) |
結果 |
WA
|
実行時間 | - |
コード長 | 514 bytes |
コンパイル時間 | 41 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 05:29:13 |
合計ジャッジ時間 | 3,712 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 99 WA * 8 |
ソースコード
import sys import math N=input() isok=[0]*100 vis=[0]*100 for i in range(2,100): for j in range(2,i): if i%j==0: isok[i]=1 def ok(N,M): q=[1] while len(q) > 0: v = q[-1] q.pop() for t in (v-1,v+1,v-M,v+M): if v%M==1 and t==v-1: continue if v%M==0 and t==v+1: continue if t<=0 or t>N: continue if isok[t] and vis[t]<M: vis[t]=M q.append(t) if vis[N]==M: return 1 return 0 if N>=50: print 8 else: for M in range(2,50): if ok(N,M): print M break