結果

問題 No.3 ビットすごろく
ユーザー lightnet328
提出日時 2017-07-01 16:01:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-10-05 04:45:21
合計ジャッジ時間 3,346 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 4 RE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def popcnt(n):
    return len(list(filter(lambda c: c == '1', list(str(bin(n))))))

def mov(e, p = 1, t = []):
    if p in t or p > e or p < 1:
        return -1

    q = popcnt(p)
    t.append(p)

    if p == e:
        return len(t)

    r = list(filter(lambda i: i >= 0, [mov(e, p + q, t), mov(e, p - q, t)]))
    if len(r) > 0:
        return min(r)
    else:
        return -1

print(mov(int(input())))
0