結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-17 18:47:59 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 5,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2024-07-01 08:40:37 |
| 合計ジャッジ時間 | 2,412 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from collections import deque
def NX(a):
global N,K
K.add(a)
r=[]
b=bin(a).count("1")
if 0 < a-b and not a-b in K:r.append(a-b)
if N >= a+b and not a+b in K:r.append(a+b)
return(r)
N=int(input())
G=-1 if N!=1 else 1
buf=deque()
buf.append([1,1])
if N==1:
buf.clear()
K=set([])
while len(buf):
c,n=buf.popleft()
if n in K:continue
for i in NX(n):
if i==N:
buf.clear()
G=c+1
buf.append([c+1,i])
print(G)