結果

問題 No.3 ビットすごろく
コンテスト
ユーザー Maboy
提出日時 2017-04-17 15:55:45
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 370 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 534 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 28,924 KB
最終ジャッジ日時 2026-04-02 14:27:19
合計ジャッジ時間 7,764 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def NX(a):
  global N,K
  K.append(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=[[1,1]] if N!=1 else []
K=[]

while len(buf):
  c,n=buf.pop(0)
  for i in NX(n):
    if i==N:
      buf.clear()
      G=c+1
    buf.append([c+1,i])
    
print(G)
0