結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
学ぶマン
|
| 提出日時 | 2025-07-04 21:54:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 5,000 ms |
| コード長 | 350 bytes |
| コンパイル時間 | 506 ms |
| コンパイル使用メモリ | 82,552 KB |
| 実行使用メモリ | 64,564 KB |
| 最終ジャッジ日時 | 2025-07-04 21:54:34 |
| 合計ジャッジ時間 | 3,207 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from collections import deque
N = int(input())
dist = [-1] * (N + 1)
dist[1] = 1
que = deque([1])
while que:
pos = que.popleft()
step = pos.bit_count()
for i in [1, -1]:
nex = pos + i*step
if 1 <= nex <= N and dist[nex] == -1:
dist[nex] = dist[pos] + 1
que.append(nex)
ans = dist[N]
print(ans)
学ぶマン