結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2018-12-01 10:03:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 526 bytes |
コンパイル時間 | 125 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 110,876 KB |
最終ジャッジ日時 | 2024-06-26 23:57:33 |
合計ジャッジ時間 | 6,836 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 TLE * 1 -- * 29 |
ソースコード
from collections import deque from copy import deepcopy def convert_bit(x): return bin(x).count("1") N = int(input()) q = deque([[1]]) while q != deque([]): root = q.popleft() last = root[-1] if last in root[:-2] or last > N: continue if last == N: print(len(root)) exit() move = convert_bit(last) if 0 < last - move: new_root = deepcopy(root) new_root.append(last - move) q.append(new_root) root.append(last + move) q.append(root) print(-1)