結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
Twizz
|
| 提出日時 | 2017-02-24 13:30:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 468 bytes |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2025-01-02 22:00:48 |
| 合計ジャッジ時間 | 2,362 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 20 |
ソースコード
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])
Twizz