← All problemsSign in

The Gifting Problem

CodeChefRating 2845Open on judge ↗

Consider $N$ families (numbered $0$ through $N-1$). Each year, each family gives gifts to all other families based on the gifts they received in the previous year. Let's say that in some year, family $i$ received gifts with value $a_i$ (from all families in total). Then, for each valid $j$, the value of the gifts given by family $i$ to family $j$ in the next year is $G(i, j) \cdot a_i$, where $G(i

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