We’d love to hear any feedback or comment from you!

###### Math · Statistics And Probability
Question details

You are given N boxes indexed from 1 to N.

Each box contains either no coins , one coin or two coins

The number of empty boxes and the number of boxes with one coin or two coins are denoted by n0 ,n1,n2 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.

What is the probability that the total number of coins in a random subset is divisible by 3.

### Constraint:

N = n0 + n1 + n2 < 100000

### EXAMPLES

#### 1

- Input: n0 = 0, n1 = 1, n2 = 0

- Output: 0.5

- Explanation: There are two subsets: [] and [1]. Only the sum of [] is a multiple of 3.

#### 2

- Input: n0 = 0, n1 = 2, n2 = 0

- Output: 0.25

- Explanation: There are four subsets: [], [1], [1], and [1, 1]. Only the sum of [] is a multiple of 3.

#### 3

- Input: n0 = 1, n1 = 1, n2 = 1

- Output: 0.5

- Explanation: There are eight subsets and the following four have a sum that is a multiple of 3: [], [0], [1, 2], and [0, 1, 2].