← All problemsSign in

Xor Becoming Uncanny

CodeChefRating 2576Open on judge ↗

We define $f(x)=\begin{cases} f(x \oplus reverse(x))+1 & \text{if } x \neq 0 \\ 0 & \text{otherwise} \end{cases}$ Here, $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) and $reverse$ is a function that takes a postive integer, reverses its binary representation (without any leading zeros) and returns the resulting number. For example $reverse(2)=

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start