← All problemsSign in

Chef and powers of 2

Codegolf Problem Statement Any even number can be expressed as sum of positive powers of 2 . For example 30 = 2 + 4 + 8 + 16 . Given a positive even number N, output the powers of 2 in ascending order whose sum is N . Input An even integer n Output Output the positive powers of 2 in ascending order whose sum is N . Constraints - 2 N 109 - N is even Example Input: 10 Output: 2 8 Input:

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