A bottle initially contains H half-pills and W whole pills.
Each day:
-
You randomly select
one pill uniformly
from the bottle.
-
If it is a
half-pill
, you consume it entirely (it is removed).
-
If it is a
whole pill
, you consume
half
and put the
remaining half
back into the bottle. (So selecting a whole pill decreases the number of whole pills by 1 and increases the number of half-pills by 1.)
You always consume exactly half a pill per day.
Task: Compute the expected number of days until the bottle contains no whole pills (i.e., only half-pills remain).
Input
Output
-
A floating-point number: the expected number of days until
W = 0
.
Example instance
Constraints (for your implementation)
-
You may assume
0 ≤ H, W ≤ 200
(or similar), and you should output the expectation with reasonable precision (e.g.,
1e-6
).