Alice has \(N\) varieties chocolates with quantities \(A_1, A_2, ..., A_N\). But the problem with them is that if he eats one chocolate of some variety, then all the other chocolates of that variety vanishes. He also has a special type of chocolate with quantity \(A_0\), if he eats one chocolate of that type then all the chocolates of all the variety vanish.
What is the expected number of chocolates he will eat till all the chocolates of all the variety vanishes. Your answer would be considered correct if it has a precision of exactly 6 decimal places.
Constraints:
\( 1 <= N <= 3 * 10^{6} \)
\( 1 <= A_i <= 3 * 10^{6} \) for \( 0 <= i <= N \)
Format of the input file:
First line : Two space separated integers \(N\) and \(A_0\), as stated above.
Second line : \(N\) space separated integers i.e. \(A_1, A_2, ..., A_N\).
Format of the output file:
Print the answer.
1 1 2
1.666667
Lets the one variety be \( A_1 \) and the special variety be \( A_0 \) . There are 2 possible cases in which Alice can think of eating the chocolate
\( A_0\) :- .If he eats chocolate of type 0 which will vanish all other chocolates. \( P(A_0 ) = 1/3\)
\( A_1,A_0 \) :- If he eats chocolate of type 1 and then chocolate of type 0. \(P( A_1,A_0 ) = 2/3\)
So, the expected number of chocolates will be \(1*P(A_0) + 2*P(A_1,A_0)= 1.666667 \) .
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor