ConstructXor
You are given two integers $N$ and $S$. Find *any* array $A = [A_1, A_2, \ldots, A_N]$ of length $N$ such that: - Each $A_i$ is a **positive** integer. - The sum of the array is $S$, i.e, $A_1 + A_2 + \ldots + A_N = S$. - The [bitwise XOR]((https://en.wikipedia.org/wiki/Bitwise_operation#XOR)) of the array is $0$, i.e, $A_1\oplus A_2\oplus\ldots\oplus A_N = 0$. If multiple valid arrays exist, y
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.
Sign in to chat with the tutor and save your progress.
Sign in to start