← All problemsSign in

The XOR Machine

CodeChefRating 2896Open on judge ↗

You are given $4$ integers $X, L, R, $ and $M$. Consider the sequence of integers $A$ of length $R-L+1$, defined by $$ A_i = (X \oplus (L + i - 1)) \bmod M $$ where where $\oplus$ is the [Bitwise xor operator](https://en.wikipedia.org/wiki/Exclusive_or). That is, the $i$-th element of the sequence is obtained by taking the result of the bitwise XOR of $X$ and $(L + i - 1)$, and computing its

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