結果

問題 No.3 ビットすごろく
ユーザー bellangeldindonbellangeldindon
提出日時 2017-06-01 22:12:28
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 348 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 7,104 KB
実行使用メモリ 6,472 KB
最終ジャッジ日時 2023-10-21 20:17:33
合計ジャッジ時間 1,722 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,408 KB
testcase_01 AC 12 ms
6,408 KB
testcase_02 AC 12 ms
6,408 KB
testcase_03 AC 14 ms
6,408 KB
testcase_04 AC 11 ms
6,408 KB
testcase_05 AC 19 ms
6,408 KB
testcase_06 AC 14 ms
6,408 KB
testcase_07 AC 13 ms
6,408 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 19 ms
6,408 KB
testcase_13 AC 13 ms
6,408 KB
testcase_14 AC 26 ms
6,420 KB
testcase_15 AC 32 ms
6,436 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 12 ms
6,408 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 11 ms
6,408 KB
testcase_22 AC 25 ms
6,420 KB
testcase_23 AC 33 ms
6,436 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 11 ms
6,408 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 11 ms
6,408 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def bitone(n):
	cnt = 0
	while n > 0:
		if n % 2 == 1:
			cnt += 1
		n = n / 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