結果
問題 | No.3 ビットすごろく |
ユーザー | papinnie |
提出日時 | 2019-08-06 20:05:02 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 763 bytes |
コンパイル時間 | 996 ms |
コンパイル使用メモリ | 10,748 KB |
実行使用メモリ | 8,776 KB |
最終ジャッジ日時 | 2023-09-25 18:06:17 |
合計ジャッジ時間 | 4,704 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,032 KB |
testcase_01 | AC | 16 ms
8,128 KB |
testcase_02 | AC | 16 ms
7,780 KB |
testcase_03 | AC | 465 ms
8,452 KB |
testcase_04 | AC | 16 ms
8,248 KB |
testcase_05 | RE | - |
testcase_06 | AC | 552 ms
8,516 KB |
testcase_07 | AC | 16 ms
8,160 KB |
testcase_08 | WA | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | AC | 306 ms
8,404 KB |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 16 ms
8,248 KB |
testcase_19 | RE | - |
testcase_20 | WA | - |
testcase_21 | AC | 15 ms
8,040 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 | AC | 15 ms
8,192 KB |
testcase_32 | RE | - |
ソースコード
N = int(input()) def get_total(x): return sum(map(int,list("{0:b}".format(x)))) already = set() def go_next(now, mv_count): already.add(now) mv_count += 1 step = get_total(now) # 進める数 #print("now", now, "mv_count", mv_count, "step", step) go_m = now + step # 進む先 if go_m == N: # goal print(mv_count) exit(0) if go_m < N: go_next(go_m, mv_count) back_m = now - step # 戻る先 if back_m not in already: # 行ったことのあるところなら行かない if back_m > 0: go_next(back_m, mv_count) if N == 1: print(1) else: # 今=1, ステップ=1で再帰スタート go_next(1, 1) # 到達できなかった print(-1)