Alex went to Las Vegas on a long vacation. He wants to play a modified Roulette game and wishes to win
money.Modified Roulette game has the following rules:
A player spins ball around a tilted circular track running around the outer edge of the wheel. The ball eventually loses momentum, passes through an area of deflectors, and falls onto one of the m pockets on the wheel, numbered from 1 to m.
A player spins ball n times. If the minimum numbered pocket across the n attempts is x. the player gains/loses a value equal to outcome[x]
Being a mathematician, Alex decides to take calculated risk by calculating the expected value he can win/lose.
Complete the print ExpectedValue function in the
editor below. it takes 2 parameters: an integer n,
and an array of m integers, outcome
Input Format
First line contains n.
Second line contains m.
Following m lines contain the ith element of outcome
First line contains n.
Second line contains m.
Following m lines contain the ith element of
outcome.
Constraints
. 1<=m<=10
.1<=n<=6
. |outcome | < 10^3,i<=m
Output Format
The function must print, to std output, the expected
value Alex will win/lose if he plays the game.
The answer will be considered correct if its relative
or absolute error doesn't exceed 10^-4.
Sample Input 0
1
1
10
Sample Output 0
10.0000
Explanation 0
Since there is only 1 pocket in the wheel. It is
always going to be the smallest numbered pocket
where the ball falls.
Hence, the answer is 10.0000.
Sample Input 1
1
2
-4
6
Sample Output 1
1.0000
Explanation 1
There are 2 pockets in the wheel, and only 1 spin.
Therefore the probability of each possible case is
Therefore the answer is 0.5"(-4) + 0.5*(6) =1