結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2021-03-27 19:36:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 69 ms / 5,000 ms |
コード長 | 450 bytes |
コンパイル時間 | 103 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-11-29 08:24:56 |
合計ジャッジ時間 | 3,027 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
import queue N = int(input()) lst = [] lst += [-1] * (N+10) 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])