QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 64 MB 總分: 100

#18088. 杰克与吉尔

统计

有 $n$ 名男性和 $n$ 名女性参加一场舞蹈比赛。比赛按照以下规则进行:

  1. 最初,男性和女性被随机配成 $n$ 对舞伴,所有舞伴围成一个圆圈。
  2. 裁判掷硬币决定数字 $k$,其值为 1 或 2,概率相等。之后,再掷一次硬币决定“顺时针”或“逆时针”方向,概率也相等。
  3. 根据上一步掷硬币的结果,女性在圆圈上沿相应方向移动 $k$ 个位置来更换舞伴(男性保持位置不变)。
  4. 如果移动后,某位女性匹配到了一位她之前已经跳过舞的男性,则比赛结束,裁判确定获胜者。否则,当前的舞伴组合进行一轮舞蹈,裁判进行评估,然后过程回到第 2 步。

确定比赛中将进行的轮数的期望值。

输入格式

一行,包含一个整数 $n$ ($2 \le n \le 50$)。

输出格式

输出答案,精度要求为 $10^{-9}$。

样例

输入 1

3

输出 1

2.50000000000000000000

输入 2

5

输出 2

3.21875000000000000000

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.