結果
問題 | No.3 ビットすごろく |
ユーザー | maburoe |
提出日時 | 2019-05-28 14:09:10 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 784 bytes |
コンパイル時間 | 91 ms |
コンパイル使用メモリ | 11,908 KB |
実行使用メモリ | 10,728 KB |
最終ジャッジ日時 | 2023-10-17 18:23:13 |
合計ジャッジ時間 | 2,503 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,112 KB |
testcase_01 | AC | 29 ms
10,112 KB |
testcase_02 | AC | 30 ms
10,112 KB |
testcase_03 | AC | 47 ms
10,332 KB |
testcase_04 | AC | 33 ms
10,152 KB |
testcase_05 | AC | 91 ms
10,728 KB |
testcase_06 | AC | 49 ms
10,344 KB |
testcase_07 | AC | 40 ms
10,228 KB |
testcase_08 | AC | 78 ms
10,564 KB |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 88 ms
10,720 KB |
testcase_13 | AC | 44 ms
10,308 KB |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 42 ms
10,240 KB |
testcase_19 | RE | - |
testcase_20 | AC | 32 ms
10,148 KB |
testcase_21 | AC | 28 ms
10,112 KB |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | AC | 28 ms
10,112 KB |
testcase_27 | AC | 47 ms
10,316 KB |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | AC | 29 ms
10,112 KB |
testcase_31 | AC | 29 ms
10,116 KB |
testcase_32 | RE | - |
ソースコード
goal = int(input()) # goal_1bit_num = bin(goal) # print(goal_1bit_num.count('1')) stepped = dict() maybe_answers = set() def step(position, count): if position in stepped: if count < stepped[position]: stepped[position] = count else: return else: stepped[position] = count if position not in range(1, goal + 1): return if len(maybe_answers) > 0 and count > min(maybe_answers): return if position == goal: maybe_answers.add(count) return position_bin = bin(position) step(position + position_bin.count('1'), count + 1) step(position - position_bin.count('1'), count + 1) step(1, 1) if len(maybe_answers) == 0: print('-1') else: print(min(maybe_answers))