結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-19 19:17:11 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 83 ms / 5,000 ms |
| + 330µs | |
| コード長 | 269 bytes |
| 記録 | |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 95,828 KB |
| 実行使用メモリ | 83,968 KB |
| 最終ジャッジ日時 | 2026-09-04 15:53:09 |
| 合計ジャッジ時間 | 4,994 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
from collections import deque
N = int(input())
cnt = [-1]*(N+1)
cnt[1] = 1
que = deque([1])
while que:
i = que.popleft()
d = i.bit_count()
for j in [i - d, i + d]:
if 1 <= j <= N and cnt[j] == -1:
cnt[j] = cnt[i] + 1
que.append(j)
print(cnt[N])