結果

問題 No.3 ビットすごろく
ユーザー sue_charosue_charo
提出日時 2017-04-12 16:18:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 575 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,744 KB
実行使用メモリ 8,692 KB
最終ジャッジ日時 2023-09-25 13:05:22
合計ジャッジ時間 2,023 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,764 KB
testcase_01 AC 16 ms
7,824 KB
testcase_02 AC 17 ms
7,940 KB
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 WA -
testcase_21 AC 15 ms
7,760 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 16 ms
8,208 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 WA -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
N = int(input())


def search_move(num):
    count = 0
    for i in list(bin(num)):
        if i == "1":
            count += 1
    return count


if N == 1:
    print(1)
    quit()

memo = [0] * (N + 1)


def move(count=1, num=1):
    global memo
    if num == N:
        return count

    if num <= 0 or num > N:
        return -1
    else:
        if memo[num] == 1:
            return -1
        
        memo[num] = 1
        move_num = search_move(num)
        return max(move(count + 1, num - move_num), move(count + 1, num + move_num))

print(move())
0