QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100
الإحصائيات

假设有 $n-1$ 个人,他们的技能水平分别为 $a_1, a_2, \dots, a_{n-1}$,正排成一队准备参加一场石头剪刀布锦标赛。你的技能水平为 $x$。请计算当你插入队列中的任意 $n$ 个位置(在第 1 个人之前、在第 1 个人和第 2 个人之间、……、在第 $n-1$ 个人之后)时,你赢得锦标赛的概率:

  • 当队列中至少有两个人时,从队首弹出两个人进行比赛(如果技能水平为 $p$ 和 $q$ 的人进行比赛,前者获胜的概率为 $\frac{p}{p+q}$,后者获胜的概率为 $\frac{q}{p+q}$,没有平局);
  • 比赛的胜者被排到队尾,败者被淘汰;
  • 最后留在队列中的人即为锦标赛的获胜者。

输入格式

第一行包含两个整数 $n$ 和 $x$ ($2 \le n \le 4096$; $n = 2^k$,其中 $k$ 为整数; $1 \le x \le 10^4$)。

第二行包含 $n-1$ 个整数 $a_1, a_2, \dots, a_{n-1}$ ($1 \le a_i \le 10^4$)。$a_1$ 是队首人的技能水平,$a_{n-1}$ 是队尾人的技能水平。

输出格式

对于你可以在队列中插入的 $n$ 个位置,从队首到队尾,依次输出你赢得锦标赛的概率。

如果你的答案的绝对误差或相对误差不超过 $10^{-9}$,则被视为正确。

样例

输入 1

4 2
1 1 1

输出 1

0.444444444444444
0.444444444444444
0.444444444444444
0.444444444444444

输入 2

4 3
4 5 2

输出 2

0.188265306122449
0.188265306122449
0.239285714285714
0.239285714285714

输入 3

8 8
1 2 3 4 5 6 7

输出 3

0.393768719371413
0.393768719371413
0.353382184051268
0.353382184051268
0.248207450668989
0.248207450668989
0.230924146560510
0.230924146560510

说明

在第一个测试用例中,你以 $\frac{2}{3}$ 的概率击败任何对手。要赢得锦标赛,你需要击败两名对手,因此无论你的初始位置如何,答案都是 $\frac{4}{9}$。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.