結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2020-08-25 02:12:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 41 ms / 5,000 ms |
コード長 | 420 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-07-01 09:54:05 |
合計ジャッジ時間 | 2,250 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
from collections import deque def bc(x): return bin(x).count("1") m=int(input()) st=[-1]*(m+1) st[1]=1 q=deque() q.append(1) while len(q)!=0: cur = q.popleft() curbc=bc(cur) if cur+curbc<=m: if st[cur+curbc]==-1: st[cur+curbc]=st[cur]+1 q.append(cur+curbc) if cur-curbc>=1 and st[cur-curbc]==-1: st[cur-curbc]=st[cur]+1 q.append(cur-curbc) print(st[m])