**Trivial Case 1**

$1$ will be represented using $1$ for all base $b \geq 2$.

**Trivial Case 2**

$2$ is represented as $10$ in base -2. For other bases, it will be $2$.

**Hint 1**

For base $b \geq X$, the number will be represented as $X$.

**Hint 2**

For any number $X (>3)$, it can be represented using $1$s in base $b = X - 1$. The representation will be $11$.

**Hint 3**

It is guaranteed that the number of bits in the lucky numbers will not exceed the number of bits in $N$.

**Hint 4**

Avoid duplicates (Same numbers represented using only 1s in more than 2 bases).

**Solution***Key Idea:* For any number$X \geq 3$ can be represented using only 1s in base $2 \leq b < X - 1$, then $X$ will be lucky.

Generate strings of length $3, 4, 5, \dots,$etc. containing only 1s and figure out their values in base-2, 3, … considering the limits discussed above.

All the generated values will be lucky numbers.

63% Solution Ratio

UshanGhoshEarliest,

fakhrulsojibFastest, 0.0s

fakhrulsojibLightest, 131 kB

MatrixShortest, 204B

Toph uses cookies. By continuing you agree to our Cookie Policy.