結果

問題 No.3 ビットすごろく
コンテスト
ユーザー kanoekakihito
提出日時 2016-09-23 22:11:51
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
MLE  
実行時間 -
コード長 415 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 522 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 705,564 KB
最終ジャッジ日時 2026-05-12 14:25:15
合計ジャッジ時間 7,778 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 MLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())

prev = [[1, []]]
end_flag = False
c = 1

while len(prev) != 0:
	next = []
	for p in prev:
		if p[0] == n:
			print(c)
			end_flag = True
			break
		b = bin(p[0])[2:].count("1")
		for i in range(2):
			next_place = p[0] + b * (-1) ** i
			if 1 <= next_place <= n and not next_place in p[1]:
				next.append([next_place,  p[1] + [p[0]]])
	if end_flag:
		break
	c += 1
	prev = next
	
else:
	print(-1)
0