#abc266e. E - Throwing the Die

E - Throwing the Die

Score : 500500 points

问题陈述

让我们用一个骰子来玩一个游戏。游戏最多包含 NN 轮,每轮的规则如下:

  • 投掷一个六面骰子,其上的数字 1,,61,\ldots,6 出现的概率相等,并令 XX 为所显示的数字(每次投掷与其他投掷相互独立)。
  • 如果现在是第 NN 轮,你的 得分XX,游戏结束。
  • 否则,你可以选择继续游戏或结束游戏。
    • 如果你选择结束游戏,你的得分即为 XX,且不再进行更多轮次。

当你以最大化期望值的方式来玩游戏时,求你的得分的期望值。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Let us play a game using a die. The game consists of at most NN turns, each of which goes as follows.

  • Throw a 66-sided die that shows 1,,61,\ldots,6 with equal probability, and let XX be the number shown (each throw is independent of the others).
  • If it is the NN-th turn now, your score is XX, and the game ends.
  • Otherwise, choose whether to continue or end the game.
    • If you end the game, your score is XX, and there is no more turn.

Find the expected value of your score when you play the game to maximize this expected value.

Constraints

  • 1N1001 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

NN

Output

Print the answer.
Your output is considered correct if its absolute or relative error from the true answer is at most 10610^{-6}.

Sample Input 1

1

Sample Output 1

3.5000000000

Sample Input 2

2

Sample Output 2

4.2500000000

Sample Input 3

10

Sample Output 3

5.6502176688

update @ 2024/3/10 11:15:06