Expected Eyes

시간 제한4초메모리 제한1024 MB

요약
면이 2개에서 8개인 주사위를 최대 8개 던질 때 모든 눈의 합의 기댓값을 출력한다.
난이도

쉬움10점 중 2점

유형
수학, 확률, 구현
정답자
아직 제출이 없습니다

문제

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:

  • 22 by throwing (1,1)(1, 1)
  • 33 by throwing (1,2)(1, 2) or (2,1)(2, 1)
  • 44 by throwing (2,2)(2, 2) or (3,1)(3, 1)
  • 55 by throwing (3,2)(3, 2)

We then sum all the outcomes and divide them by the number of possible throws.

E\[X]=2⋅1+3⋅2+4⋅2+5⋅16=216=3.5E\[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 nn (1≤n≤81 \leq n \leq 8), the number of dice.
  • One line with nn integers xx (2≤x≤82 \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−610^{-6}.

예제3

  1. 예제 1

    입력
    1
    6
    
    예상 출력
    3.5
    
  2. 예제 2

    입력
    2
    3 2
    
    예상 출력
    3.5
    
  3. 예제 3

    입력
    5
    3 6 2 8 8
    
    예상 출력
    16.0