結果
問題 | No.3 ビットすごろく |
ユーザー |
|
提出日時 | 2016-07-19 00:51:09 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 41 ms / 5,000 ms |
コード長 | 538 bytes |
コンパイル時間 | 121 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-07-01 08:01:33 |
合計ジャッジ時間 | 2,215 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
N = int(input())queue = [1]visited = set()count = 0while queue:count += 1n = []flg = Falsefor i in queue:if i == N:print(count)flg = Truebreakb1_num = bin(i).count('1')a = i + b1_numb = i - b1_numif a <= N and a not in visited:visited.add(a)n.append(a)if 1 < b and b not in visited:visited.add(b)n.append(b)queue = nif(flg):breakelse:print(-1)