P6124 [NEERC 2015] Binary vs Decimal

Description

A positive number $A$ is considered valid if it contains only `0` or `1`, and after converting it to binary as $B$, $A$ is a suffix of $B$. Now you are given a number $N$. Find the $N$-th such number.

Input Format

One line with one number $N$.

Output Format

One line with one number: the $N$-th number.

Explanation/Hint

$1 \le N \le 10^4$. |Original|Binary|Comment| | :-----------: | :-----------: | :-----------: | |$1$|$1$|√| |$10$|$1010$|√| |$11$|$1011$|√| |$100$|$1100100$|√| |$101$|$1100101$|√| |$110$|$1101110$|√| |$111$|$1101111$|√| |$1000$|$1111101000$|√| |$1001$|$1111101001$|√| |$1010$|$1111110010$|×| |$1011$|$1111110011$|×| |$1100$|$10001001100$|√| Translated by ChatGPT 5