Logo
(追記) (追記ここまで)

32612번 - Expected Eyes 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB98805882.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:

  • 2ドル$ by throwing $(1, 1)$
  • 3ドル$ by throwing $(1, 2)$ or $(2, 1)$
  • 4ドル$ by throwing $(2, 2)$ or $(3, 1)$
  • 5ドル$ by throwing $(3, 2)$

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:

  • One line with an integer $n$ (1ドル \leq n \leq 8$), the number of dice.
  • One line with $n$ integers $x$ (2ドル \leq x \leq 8$), the number of faces on each die.

출력

Output the expected value of throwing all dice.

Your answer should have an absolute or relative error of at most 10ドル^{-6}$.

제한

예제 입력 1

1
6

예제 출력 1

3.5

예제 입력 2

2
3 2

예제 출력 2

3.5

예제 입력 3

5
3 6 2 8 8

예제 출력 3

16.0

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2023 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /