結果

問題 No.3 ビットすごろく
ユーザー TawaraTawara
提出日時 2015-09-12 15:35:05
言語 Python2
(2.7.18)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 234 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 6,616 KB
実行使用メモリ 6,344 KB
最終ジャッジ日時 2023-09-13 23:23:55
合計ジャッジ時間 1,988 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,012 KB
testcase_01 AC 12 ms
5,936 KB
testcase_02 AC 12 ms
6,036 KB
testcase_03 AC 16 ms
6,120 KB
testcase_04 AC 12 ms
5,932 KB
testcase_05 AC 19 ms
6,068 KB
testcase_06 AC 17 ms
6,068 KB
testcase_07 AC 14 ms
6,048 KB
testcase_08 AC 17 ms
6,096 KB
testcase_09 AC 20 ms
6,336 KB
testcase_10 AC 22 ms
6,252 KB
testcase_11 AC 19 ms
6,136 KB
testcase_12 AC 17 ms
6,112 KB
testcase_13 AC 14 ms
6,240 KB
testcase_14 AC 22 ms
6,140 KB
testcase_15 AC 24 ms
6,244 KB
testcase_16 AC 22 ms
6,316 KB
testcase_17 AC 24 ms
6,232 KB
testcase_18 AC 13 ms
6,108 KB
testcase_19 AC 24 ms
6,148 KB
testcase_20 AC 12 ms
6,056 KB
testcase_21 AC 12 ms
5,924 KB
testcase_22 AC 21 ms
6,212 KB
testcase_23 AC 25 ms
6,236 KB
testcase_24 AC 24 ms
6,344 KB
testcase_25 AC 24 ms
6,144 KB
testcase_26 AC 12 ms
6,016 KB
testcase_27 AC 14 ms
6,144 KB
testcase_28 AC 22 ms
6,324 KB
testcase_29 AC 20 ms
6,048 KB
testcase_30 AC 12 ms
6,136 KB
testcase_31 AC 12 ms
5,980 KB
testcase_32 AC 19 ms
6,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
v = [N+1]*N
v[0] = 1
Q = [0]
while Q:
	h = Q.pop(0)
	if h == N-1:
		print v[h]
		break
	m = bin(h+1).count("1")
	c = v[h]+1
	for nh in [h-m,h+m]:
		if -1 < nh < N and v[nh] > c:
			Q.append(nh)
			v[nh] = c
else:
	print -1
0