結果

問題 No.3 ビットすごろく
ユーザー lenoleno
提出日時 2017-08-03 14:34:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-20 01:34:18
合計ジャッジ時間 2,058 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

from builtins import print

global N
N = int(input())
L = 1
add = 1
cnt = 1
global List
List = []
Reach = 10001 * [False]


def dfs(L, addlen, cnt) :
    if L > N+1 or L < 1 or Reach[L] == True:
        return

    Reach[L] = True
    L += int(addlen)

    if L == N :
        List.append(cnt)
        return

    dfs(L, str(bin(L).count("1")), cnt + 1)
    dfs(L, str(bin(L).count("1")) * -1, cnt + 1)

dfs(L, add, cnt + 1)
try :
    m = min(List)
except ValueError :
    m = -1

print(m)
0