結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,784 KB
testcase_01 AC 15 ms
7,784 KB
testcase_02 AC 15 ms
7,768 KB
testcase_03 AC 68 ms
8,332 KB
testcase_04 AC 21 ms
8,224 KB
testcase_05 AC 244 ms
8,560 KB
testcase_06 AC 75 ms
8,248 KB
testcase_07 AC 36 ms
8,208 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 230 ms
8,428 KB
testcase_13 AC 50 ms
8,220 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 40 ms
8,268 KB
testcase_19 RE -
testcase_20 WA -
testcase_21 AC 14 ms
7,860 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 15 ms
7,788 KB
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 AC 15 ms
7,864 KB
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

nin = int(input())
visit = []
mark = 100000
def dps(n,m=1):
  if n == nin:
    visit.append(n)
    global mark
    mark = min(m,mark)
    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