結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,880 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 90 ms
10,880 KB
testcase_04 AC 38 ms
10,752 KB
testcase_05 AC 305 ms
11,264 KB
testcase_06 AC 103 ms
10,880 KB
testcase_07 AC 57 ms
10,880 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 287 ms
11,008 KB
testcase_13 AC 73 ms
10,880 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 64 ms
10,880 KB
testcase_19 RE -
testcase_20 WA -
testcase_21 AC 31 ms
10,752 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 30 ms
10,752 KB
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 AC 31 ms
10,752 KB
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:
        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