← All problemsSign in

Binary Ternary

Chef has given you a number $N$. Your task is to represent $N$ as: $N = 2^{a_1} + 2^{a_2} + \ldots + 2^{a_{k_1}} + 3^{b_1} + 3^{b_2} + \ldots + 3^{b_{k_2}}$ such that: - The values $\{a_1, a_2, \ldots, a_{k_1}\}$ are all **distinct**; - The values $\{b_1, b_2, \ldots, b_{k_2}\}$ are all **distinct**; - The value $(k_1 + k_2)$ is **minimum**. If it is not possible to represent $N$ in the given

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