Sum By OR
Let $f(X, Y) = \left \lceil \dfrac{X + Y}{X | Y} \right \rceil$, i.e. the result of $X + Y$ divided by $X | Y$ rounded up, where $|$ denotes the Bitwise OR symbol. You are given an array $A$ of length $N$. Your task is to compute $\sum_{i = 1}^{N} \sum_{j = i + 1}^{N} f(A_i, A_j)$, i.e. the sum of $f$ over all pairs in the array $A$. **Note** : There is an additional constraint on the input th
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