結果

問題 No.3 ビットすごろく
ユーザー lightnet328lightnet328
提出日時 2017-07-01 16:00:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-04-15 10:29:29
合計ジャッジ時間 7,536 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
10,752 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 OLE -
testcase_06 WA -
testcase_07 AC 36 ms
11,008 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 OLE -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 36 ms
10,880 KB
testcase_19 RE -
testcase_20 WA -
testcase_21 AC 34 ms
10,880 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 33 ms
10,752 KB
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 WA -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

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:
        print(e, p, t, "E")
        return -1

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

    if p == e:
        print(len(t))
        sys.exit(0)

    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