102664: [AtCoder]ABC266 E - Throwing the Die

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:4 Solved:0

Description

Score : $500$ points

Problem Statement

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

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

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

Constraints

  • $1 \leq N \leq 100$

Input

Input is given from Standard Input in the following format:

$N$

Output

Print the answer.
Your output is considered correct if its absolute or relative error from the true answer is at most $10^{-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

Input

题意翻译

你有一个普通均匀的正方体骰子,六个面写有 $1,2,3,4,5,6$。你在玩一个游戏,每次丢骰子之后,你可以: - 如果这是你的第 $N$ 次投掷,那么你应当结束游戏。 - 否则你可以选择重新投,或者结束游戏。 给定 $N$,计算如果你希望**最后一次投掷**时朝上面的**期望**最大,那么这个期望是多少。

Output

分数:500分

问题描述

让我们玩一个用骰子玩的游戏。游戏最多包含$N$轮,每轮如下进行。

  • 投掷一个等概率显示$1,\ldots,6$的六面骰子,让$X$表示显示的数字(每次投掷与其他投掷相互独立)。
  • 如果现在是第$N$轮,你的< strong>分数 是$X$,游戏结束。
  • 否则,选择是继续还是结束游戏。
    • 如果你结束游戏,你的分数是$X$,没有更多的回合。

找到你玩游戏时的期望分数,以最大化这个期望分数。

约束

  • $1 \leq N \leq 100$

输入

从标准输入以以下格式给出输入:

$N$

输出

打印答案。
你的输出被认为是正确的,如果它与真实答案的绝对或相对误差不超过$10^{-6}$。


样例输入1

1

样例输出1

3.5000000000

样例输入2

2

样例输出2

4.2500000000

样例输入3

10

样例输出3

5.6502176688

加入题单

算法标签: