結果

問題 No.3 ビットすごろく
コンテスト
ユーザー bellangeldindon
提出日時 2017-06-01 22:20:48
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 355 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 162 ms
コンパイル使用メモリ 77,712 KB
最終ジャッジ日時 2025-12-03 23:53:59
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def bitone(n):
	cnt = 0
	m = n
	while m > 0:
		if m % 2 == 1:
			cnt += 1
		m = m / 2
	return cnt

def sugoroku(n):
	now = 1
	cnt = 1
	history = []
	while now < n:
		b = bitone(now)
		cnt += 1
		if now + b > n:
			now -= b
		else:
			now += b
		if now in history:
			return -1
		else:
			history.append(now)
	
	return cnt

print sugoroku(int(raw_input()))
0