結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 114 ms
77,008 KB
testcase_04 AC 60 ms
72,656 KB
testcase_05 AC 176 ms
77,776 KB
testcase_06 AC 117 ms
77,008 KB
testcase_07 AC 83 ms
75,856 KB
testcase_08 AC 158 ms
77,392 KB
testcase_09 AC 193 ms
78,800 KB
testcase_10 AC 248 ms
82,264 KB
testcase_11 AC 187 ms
78,288 KB
testcase_12 AC 177 ms
77,776 KB
testcase_13 AC 110 ms
77,008 KB
testcase_14 AC 247 ms
82,128 KB
testcase_15 AC 279 ms
88,016 KB
testcase_16 AC 276 ms
83,664 KB
testcase_17 AC 306 ms
84,176 KB
testcase_18 AC 83 ms
75,984 KB
testcase_19 AC 290 ms
94,032 KB
testcase_20 AC 56 ms
70,608 KB
testcase_21 AC 36 ms
53,460 KB
testcase_22 AC 249 ms
82,128 KB
testcase_23 AC 297 ms
94,800 KB
testcase_24 AC 287 ms
94,052 KB
testcase_25 AC 281 ms
88,016 KB
testcase_26 WA -
testcase_27 AC 113 ms
77,008 KB
testcase_28 AC 276 ms
83,664 KB
testcase_29 AC 202 ms
78,416 KB
testcase_30 AC 44 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, count = reach | check | left | right, (left | right) - reach, count + 1
print(count if N in reach else -1)	
0