← All problemsSign in

Random OR

CodeChefRating 2891Open on judge ↗

Chef is playing a game, which he starts with a score of $S = 0$. He also has an integer $N$. In one move, Chef does the following: - Uniformly randomly pick an integer $X$ between $0$ and $2^N - 1$ (inclusive of both ends) - Update his score as $S \rightarrow S \mid X$, where $\mid$ denotes the [bitwise OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR) operation For example, if Chef's curr

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