| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 | 1024 MB | 98 | 80 | 58 | 82.857% |
Once upon a time, in a small kingdom in the Faraway Province of Combinatorics the king was obsessed with dice. He had a collection of multi-faced dice from all over the world, and he loved to play games with them.
One day, the king came up with a new game. Every player would choose a number and then the king would roll all his dice at once. The player whose choice is closest to the value of all numbers on the dice wins. Since the king hates losing, he wanted to increase his winning chances by always choosing the expected value of his throw. Not very skilled with mathematics, he asked you to solve the following problem.
Given a list of dice and the number of faces of each one of them, calculate the expected value of throwing all of them at once.
The expected value of an event is the weighted average of all possible outcomes.
As an example, consider the second sample input. By throwing two (three- and two-sided) dice, you can get the following values:
We then sum all the outcomes and divide them by the number of possible throws.
$$E[X] = \frac{2 \cdot 1 + 3 \cdot 2 + 4 \cdot 2 + 5 \cdot 1}{6} = \frac{21}{6} = 3.5$$
The input consists of:
Output the expected value of throwing all dice.
Your answer should have an absolute or relative error of at most 10ドル^{-6}$.
1 6
3.5
2 3 2
3.5
5 3 6 2 8 8
16.0