QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 64 MB Points totaux : 100

#18088. 傑克與吉爾

Statistiques

有 $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.