If $J(n) = \displaystyle{\frac{n}{2}}$ , binary representation of $n$ will be $101010....$ . We can prove that by easy induction or basic algebra. Rest of the process is easy. Find all the numbers which satisfy this. then for Every query, loop over the numbers and count them.

83% Solution Ratio

EgorKulikovEarliest,

skmonirFastest, 0.1s

vipghn2003Lightest, 2.2 MB

Dipto_DebdipShortest, 237B

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