P1010 [NOIP 1998 Junior] Powers of Two
Description
Any positive integer can be expressed as a sum of powers of $2$. For example, $137=2^7+2^3+2^0$.
We also agree to write exponents using parentheses, i.e., $a^b$ can be written as $a(b)$.
Thus, $137$ can be written as $2(7)+2(3)+2(0)$.
Furthermore, $7= 2^2+2+2^0$ (where $2^1$ is written as $2$), and $3=2+2^0$.
Therefore, the final expression for $137$ is $2(2(2)+2+2(0))+2(2+2(0))+2(0)$.
Another example: $1315=2^{10} +2^8 +2^5 +2+1$.
Thus, the final expression for $1315$ is $2(2(2+2(0))+2)+2(2(2+2(0)))+2(2(2)+2(0))+2+2(0)$.
Input Format
One line containing a positive integer $n$.
Output Format
Output the agreed "0, 2" representation of $n$ (no spaces are allowed in the expression).
Explanation/Hint
- Constraints: For $100\%$ of the testdata, $1 \le n \le 2 \times {10}^4$.
- NOIP 1998 Junior, Problem 3.
Translated by ChatGPT 5