E - Yacht 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 475

問題文

5 個の 6 面ダイスがあります。どのダイスも各面に書かれた数は A_1,\ldots,A_66 個であり、各面が出る確率は \frac{1}{6} です。

あなたはこれらのダイスを使って次の手順で 1 人ゲームを行います。

  1. 5 個のダイスを全て振り、その結果を見て、好きな個数(0 個でもよい)のダイスをキープする。
  2. キープされていないダイスを全て振り直し、その結果を見て、振り直したダイスのうち好きな個数(0 個でもよい)のダイスを追加でキープする。前のステップでキープしたダイスはキープしたままとなる
  3. キープされていないダイスを全て振り直し、その結果を見る。
  4. 好きな数 X を選ぶ。5 個のダイスのうち X の目が出ているダイスの個数を n として、このゲームの得点は nX 点となる。

ゲームの得点の期待値を最大化するように行動するときの、ゲームの得点の期待値を求めてください。

制約

  • A_i1 以上 100 以下の整数

入力

入力は以下の形式で標準入力から与えられる。

A_1 A_2 A_3 A_4 A_5 A_6

出力

答えを出力せよ。真の解との相対誤差または絶対誤差が 10^{-5} 以下のとき正解とみなされる。


入力例 1

1 2 3 4 5 6

出力例 1

14.6588633742

例えばゲームは次のように進行します。(最適な行動とは限りません)

  1. 5 個のダイスを全て振り、それぞれ 3,3,1,5,6 の目が出る。3 の目が出た 2 個のダイスをキープする。
  2. キープされていない 3 個のダイスを振り、それぞれ 6,6,2 の目が出る。6 の目が出た 2 個のダイスを追加でキープする。
  3. キープされていない 1 個のダイスを振り、4 の目が出る。
  4. X として 6 を選ぶ。5 個のダイスの出目はそれぞれ 3,3,6,6,4 なので、6 の目が出ているダイスの個数は 2 であり、このゲームの得点は 12 となる。

このケースでは最適に行動した場合の期待値は \frac{143591196865}{9795520512}=14.6588633742\ldots となります。


入力例 2

1 1 1 1 1 1

出力例 2

5.0000000000

ダイスは同じ値が書かれた面を持つことがあります。


入力例 3

31 41 59 26 53 58

出力例 3

159.8253021021

Score : 475 points

Problem Statement

There are five six-sided dice. Each die has the numbers A_1,\ldots,A_6 written on its faces, and each face appears with probability \frac{1}{6}.

You will play a single-player game using these dice with the following procedure:

  1. Roll all five dice, observe the results, and keep any number (possibly zero) of dice.
  2. Re-roll all dice that are not kept, observe the results, and additionally keep any number (possibly zero) of the re-rolled dice. The dice kept in the previous step remain kept.
  3. Re-roll all dice that are not kept and observe the results.
  4. Choose any number X. Let n be the number of dice among the five dice that show X. The score of this game is nX points.

Find the expected value of the game score when you act to maximize the expected value of the game score.

Constraints

  • A_i is an integer between 1 and 100, inclusive.

Input

The input is given from Standard Input in the following format:

A_1 A_2 A_3 A_4 A_5 A_6

Output

Print the answer. Your answer will be considered correct if the relative or absolute error from the true value is at most 10^{-5}.


Sample Input 1

1 2 3 4 5 6

Sample Output 1

14.6588633742

For example, the game may proceed as follows (not necessarily optimal):

  1. Roll all five dice and get 3,3,1,5,6. Keep the two dice that show 3.
  2. Re-roll the three dice that are not kept and get 6,6,2. Additionally keep the two dice that show 6.
  3. Re-roll the one die that is not kept and get 4.
  4. Choose X = 6. The dice show 3,3,6,6,4, so the number of dice showing 6 is 2, and the score of this game is 12.

In this case, the expected value when acting optimally is \frac{143591196865}{9795520512}=14.6588633742\ldots.


Sample Input 2

1 1 1 1 1 1

Sample Output 2

5.0000000000

The dice may have faces with the same value written on them.


Sample Input 3

31 41 59 26 53 58

Sample Output 3

159.8253021021