結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2019-11-19 08:29:29 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 71 ms / 5,000 ms |
コード長 | 355 bytes |
コンパイル時間 | 117 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-07-01 09:33:04 |
合計ジャッジ時間 | 2,996 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
import queue N = int(input()) v = [0] * (N + 1) v[1] = 1 q = queue.Queue() q.put(1) while not q.empty(): i = q.get() if i == N: break c = format(i,'b').count('1') if i + c <= N and v[i + c] == 0: q.put(i + c) v[i + c] = v[i] + 1 if i - c > 0 and v[i - c] == 0: q.put(i - c) v[i - c] = v[i] + 1 print(v[i] if i == N else -1)