1. Math
  2. Statistics And Probability
  3. you are given n boxes indexed from 1 to n...

Question: you are given n boxes indexed from 1 to n...

Question details

You are given N boxes indexed from 1 to N. 

Each box contains either no coins or one coin. 

The number of empty boxes and the number of boxes with one coin are denoted by n0 and n1, respectively. 

You take a random subset of the boxes where each subset has the same same probability to be selected. 

The empty set and the set itself are considered a subset. 


Given n0 and n1, what is the probability that the total number of coins in the random subset is even?


### Constraint:

N = n0 + n1 < 100000




#### 1

- Input: n0 = 1, n1 = 0

- Output: 1.0

- Explanation: There are two subsets: [] and [0]. Both of them have an even sum.


#### 2

- Input: n0 = 0, n1 = 2

- Output: 0.5

- Explanation: There are four subsets: [], [1], [1], and [1, 1]. The sum of [] and [1,1] is even.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution