結果

問題 No.3 ビットすごろく
ユーザー Koharu Aoki 🌏🦊🇯🇵 青木小春Koharu Aoki 🌏🦊🇯🇵 青木小春
提出日時 2024-03-18 01:21:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 431 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 94,800 KB
最終ジャッジ日時 2024-03-18 01:21:28
合計ジャッジ時間 7,194 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 114 ms
77,008 KB
testcase_04 AC 57 ms
72,656 KB
testcase_05 AC 169 ms
77,776 KB
testcase_06 AC 115 ms
77,008 KB
testcase_07 AC 80 ms
75,856 KB
testcase_08 AC 157 ms
77,392 KB
testcase_09 AC 197 ms
78,800 KB
testcase_10 AC 261 ms
82,256 KB
testcase_11 AC 187 ms
78,288 KB
testcase_12 AC 169 ms
77,776 KB
testcase_13 AC 111 ms
77,008 KB
testcase_14 AC 248 ms
82,128 KB
testcase_15 AC 288 ms
88,016 KB
testcase_16 AC 281 ms
83,664 KB
testcase_17 AC 280 ms
84,176 KB
testcase_18 AC 81 ms
75,984 KB
testcase_19 AC 285 ms
94,032 KB
testcase_20 AC 57 ms
70,608 KB
testcase_21 AC 34 ms
53,460 KB
testcase_22 AC 255 ms
82,128 KB
testcase_23 AC 285 ms
94,800 KB
testcase_24 AC 286 ms
94,416 KB
testcase_25 AC 278 ms
87,896 KB
testcase_26 WA -
testcase_27 AC 114 ms
77,008 KB
testcase_28 AC 265 ms
83,664 KB
testcase_29 AC 186 ms
78,416 KB
testcase_30 AC 43 ms
61,716 KB
testcase_31 AC 44 ms
61,716 KB
testcase_32 AC 181 ms
77,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = [int(i) for i in input().split()][0]
count = 1 
check = set([1])
reach = set()
bitcount = lambda x : sum(int(i) for i in bin(x)[2:])
while N not in reach and len(check) > 0:
	left = set(i + bitcount(i) for i in check if i + bitcount(i) <= N)
	right = set(i - bitcount(i) for i in check if i - bitcount(i) >= 0)
	reach, check = reach | check | left | right, (left | right) - reach
	count += 1
print(count if N in reach else -1)	
0