結果

問題 No.3 ビットすごろく
ユーザー tookunn_1213tookunn_1213
提出日時 2015-08-16 13:03:01
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 467 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 6,620 KB
実行使用メモリ 11,996 KB
最終ジャッジ日時 2023-09-25 12:19:59
合計ジャッジ時間 8,938 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,056 KB
testcase_01 AC 10 ms
5,908 KB
testcase_02 AC 11 ms
5,812 KB
testcase_03 AC 63 ms
6,004 KB
testcase_04 AC 21 ms
5,844 KB
testcase_05 AC 1,208 ms
6,620 KB
testcase_06 AC 70 ms
6,208 KB
testcase_07 AC 38 ms
6,064 KB
testcase_08 AC 320 ms
6,252 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(raw_input())
queue = [1,1]
path = [False for i in range(N)]
ans = -1
while len(queue) > 0:
	now,count= queue.pop(0),queue.pop(0)
	path[now - 1] = True
	if now == N:
		ans = count
		break
	s = str(bin(now)).count('1')
	if s == 0:continue
	next1 = now + s
	next2 = now - s
	if not(next1 > N or path[next1 - 1]):
		queue.append(now + s)
		queue.append(count + 1)
	if not(next2 <= 0 or path[next2 - 1]):
		queue.append(now - s)
		queue.append(count + 1)
print ans
0