← All problemsSign in

Ada Function

CodeChefRating 3028Open on judge ↗

Ada has a set of $N$ non-negative integers $S = \{x_1, x_2, \ldots, x_N\}$. She defined the function $W$ as follows: - $W(\{\}) = 0$. - If $S = \{a\}$, then $W(S) = a$. - If $S = \{a, b\}$ (so $|S| = 2$), then $W(S) = (a \oplus b) - 1$. - If $|S| \ge 3$, then to calculate $W(S)$, find any two elements of $S$ that are congruent (have the same remainders) modulo the highest possible power of $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