P2727 [USACO3.2] 01 String Stringsobits
Background
Consider sorted $N$-bit binary numbers ($1 \leq N \leq 31$).
Description
They are sorted and include all $N$-bit binary numbers whose number of $1$s is at most $L$ ($L \leq N$).
Your task is to output the $i$-th smallest $N$-bit binary number that has at most $L$ ones (it is guaranteed to exist).
Example: In $100101$, $N = 6$, and it contains $3$ ones.
Input Format
One line with three integers $N, L, i$.
Output Format
Output the $i$-th smallest binary number that satisfies the conditions.
Explanation/Hint
Problem translation from NOCOW.
USACO Training Section 3.2.
Translated by ChatGPT 5