QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#4228. 双重排序

Statistics

给定两个整数 $n$ 和 $m$ ($n \le m$),按以下步骤生成一个包含 $n$ 个整数的序列:

  1. 首先,在 $1$ 到 $m$(包含 $1$ 和 $m$)之间选择 $n$ 个不同的整数。
  2. 将这些数按非递减顺序排序。
  3. 取差分序列,即将序列 $a_1, a_2, a_3, \dots$ 转换为 $a_1, a_2 - a_1, a_3 - a_2, \dots$。
  4. 将差分序列按非递减顺序排序。
  5. 对排序后的差分序列取前缀和,得到最终序列。即将序列 $b_1, b_2, b_3, \dots$ 转换为 $b_1, b_2 + b_1, b_3 + b_2 + b_1, \dots$。

例如,当 $n = 3$ 且 $m = 10$ 时: 1. 假设我们初始选择了 $6, 2, 9$。 2. 排序后的序列为 $2, 6, 9$。 3. 差分序列为 $2, 4, 3$。 4. 排序后的差分序列为 $2, 3, 4$。 5. 排序后差分序列的前缀和为 $2, 5, 9$。

假设你在第 1 步中均匀随机选择了一组不同的整数。请计算最终序列中每个索引位置的期望值。

输入格式

输入包含一行,包含两个整数 $n$ ($1 \le n \le 50$) 和 $m$ ($n \le m \le 10,000$),其中 $n$ 是序列的大小,所有初始选择的整数均在 $1$ 到 $m$ 的范围内。

输出格式

输出 $n$ 行。每行包含一个实数,表示最终序列中该索引位置的期望值。如果答案的绝对误差或相对误差不超过 $10^{-6}$,则视为正确。

样例

样例输入 1

3 5

样例输出 1

1
2.3
4.5

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.