結果
問題 | No.3 ビットすごろく |
ユーザー | Twizz |
提出日時 | 2017-02-24 13:30:20 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 468 bytes |
コンパイル時間 | 97 ms |
コンパイル使用メモリ | 10,720 KB |
実行使用メモリ | 7,944 KB |
最終ジャッジ日時 | 2023-08-30 23:03:45 |
合計ジャッジ時間 | 1,852 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,912 KB |
testcase_01 | WA | - |
testcase_02 | AC | 15 ms
7,836 KB |
testcase_03 | AC | 15 ms
7,840 KB |
testcase_04 | WA | - |
testcase_05 | AC | 16 ms
7,728 KB |
testcase_06 | AC | 15 ms
7,800 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 15 ms
7,816 KB |
testcase_13 | AC | 16 ms
7,904 KB |
testcase_14 | AC | 15 ms
7,824 KB |
testcase_15 | AC | 15 ms
7,780 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 15 ms
7,832 KB |
testcase_22 | AC | 15 ms
7,776 KB |
testcase_23 | AC | 15 ms
7,832 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 13 ms
7,732 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
N=int(input()) list={1:1} que=[(1,1)] loc=1 while True: cnt=que[0][0]+1 loc=que[0][1] mov=(bin(loc)).count("1") if loc+mov<=N: if loc+mov not in list: list[loc+mov]=cnt que.append((loc+mov,cnt)) if loc-mov>=1: if loc-mov not in list: list[loc-mov]=cnt que.append((loc-mov,cnt)) que.pop(0) if que==[]: break if N not in list: print(-1) else: print(list[N])