← All problemsSign in

Tom and Jerry

CodeChefRating 2688Open on judge ↗

Tom and Jerry have $B$ boxes, numbered from $1$ to $B$. Each box initially contains $M$ cheese balls and $N$ chicken bones. They perform the following process for each $i$ from $1$ to $B-1$, **in order**: - Choose $i$ random items from the $i$-th box, and transfer them to box $(i+1)$. Every subset of $i$ items is equally likely to be chosen. You are given integers $B, M, N, $ and $K$. At the

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