← All problemsSign in

3007. Maximum Number That Sum of the Prices Is Less Than or Equal to K

LeetCodeMathBinary SearchDynamic ProgrammingBit ManipulationOpen on judge ↗

You are given an integer k and an integer x. The price of a number num is calculated by the count of set bits at positions x, 2x, 3x, etc., in its binary representation, starting from the least significant bit. The following table contains examples of how price is calculated. x num Binary Representation Price 1 13 000001101 3 2 13 000001101 1 2 233 011101001 3 3 13 000001101 1 3

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start