Counting Good Numbers
You are given two positive integers $N$ and $K$. A positive integer $X$ is called a **Good Number** if $X$ can be written as $i_1\ |\ i_2\ |\ \cdots\ |\ i_M$ $^\dagger$, where $K \le i_1 < i_2 < \cdots < i_M < N + K$ and $1 \le M \le N$. Now your task is to answer $Q$ queries of the following type: - $L, R$ : count the number of **Good Numbers** between $l$ and $r$ inclusive. $^\dagger$ 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.
Sign in to chat with the tutor and save your progress.
Sign in to start