結果
問題 | 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 sysimport mathN=input()isok=[0]*100vis=[0]*100for i in range(2,100):for j in range(2,i):if i%j==0:isok[i]=1def 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:continueif v%M==0 and t==v+1:continueif t<=0 or t>N:continueif isok[t] and vis[t]<M:vis[t]=Mq.append(t)if vis[N]==M:return 1return 0if N>=50:print 8else:for M in range(2,50):if ok(N,M):print Mbreak