← All problemsSign in

Fixed Sum

CodeChefRating 3099Open on judge ↗

You are given two integers $N \ ( N \geq 2)$ and $S$. You have to construct an array $A$ containing $N$ integers such that: - $0 \leq A_i \leq S$ for each $1 \leq i \leq N$ - $A_1 + A_2 + \ldots + A_N = S$ - $A_1 \mathbin{\&} A_2 \mathbin{\&} \ldots \mathbin{\&} A_N = 0$, where $\mathbin{\&}$ denotes [bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND) operator. - The maximum element

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