結果

問題 No.3 ビットすごろく
ユーザー 1up_aloe1up_aloe
提出日時 2018-01-31 13:55:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,616 KB
実行使用メモリ 8,736 KB
最終ジャッジ日時 2023-08-28 17:29:43
合計ジャッジ時間 2,948 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,864 KB
testcase_01 AC 16 ms
7,864 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 64 ms
8,244 KB
testcase_04 AC 23 ms
8,204 KB
testcase_05 AC 244 ms
8,420 KB
testcase_06 AC 74 ms
8,264 KB
testcase_07 AC 36 ms
8,292 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 232 ms
8,520 KB
testcase_13 AC 51 ms
8,284 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 42 ms
8,200 KB
testcase_19 RE -
testcase_20 WA -
testcase_21 AC 16 ms
7,856 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 16 ms
7,756 KB
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 AC 16 ms
7,784 KB
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

nin = int(input())
visit = []
mark = 0
def dps(n,m=1):
  if n == nin:
    visit.append(n)
    global mark
    mark = m
    return
  bit = 0
  visit.append(n)
  for item in list(str(bin(n))):
    if item == "1":
      bit += 1
      
  for item in [n+bit,n-bit]:
    if item < 1 or item > nin:
      continue
    else:
      if not item in visit:
        dps(item,m+1)


dps(1)
if nin in visit:
  print(mark)
else:
  print(-1)
0