Description
Serve soup from A and B with 4 operations of different portions. Return probability A empties first + 0.5 * probability both empty together.
Examples
Input:
n = 50Output:
0.625Explanation:
Calculated probability.
Input:
n = 0Output:
0.5Explanation:
When n = 0, both soups are already empty, so they empty simultaneously. The probability of A emptying first is 0, plus half the probability of simultaneous emptying (which is 1), giving us 0.5.
Input:
n = 25Output:
0.5625Explanation:
With n = 25, there are a smaller soup amount than the existing examples. The probability calculation considers all possible serving combinations, and with fewer total servings possible, soup A has a moderate advantage in emptying first or simultaneously.
Constraints
- •
0 ≤ n ≤ 10⁹