結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2021-04-03 14:36:37 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 68 ms / 5,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-12-24 20:08:22 |
合計ジャッジ時間 | 3,212 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
import queue N = int(input()) lst = [] lst += [-1] * (N+1) lst[1] = 1 q = queue.Queue() q.put(1) while not q.empty(): current = q.get() go = bin(current).count("1") if (current - go > 0 and lst[current - go] == -1): lst[current - go] = lst[current] + 1 q.put(current - go) if (current + go <= N and lst[current + go] == -1): lst [current + go] = lst[current] + 1 q.put(current + go) print(lst[N])