結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-07-19 00:51:09 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 100 ms / 5,000 ms |
| コード長 | 538 bytes |
| 記録 | |
| コンパイル時間 | 591 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 15,708 KB |
| 最終ジャッジ日時 | 2026-03-22 04:26:49 |
| 合計ジャッジ時間 | 4,499 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
N = int(input())
queue = [1]
visited = set()
count = 0
while queue:
count += 1
n = []
flg = False
for i in queue:
if i == N:
print(count)
flg = True
break
b1_num = bin(i).count('1')
a = i + b1_num
b = i - b1_num
if 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 = n
if(flg):
break
else:
print(-1)