QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100

#8964. 期望距离

统计

Svetozar 对机器人技术充满热情。他喜欢在后院一个平坦、完美的圆形平台上测试他的机器人。今天,他邀请了 $n$ 位朋友,并将他们每个人都安置在平台的边缘(即圆周上),且每个人的位置各不相同。

Svetozar 现在计划将他的新机器人放置在平台上的某个“好点”上,然后命令它确定距离机器人第 $k$ 近的朋友(如果有多个,任选其一),并径直走向那位朋友。如果一个点满足以下条件,Svetozar 称其为“好点”:不存在一个包含所有朋友的半平面,且该半平面的边界经过该点。

现在,Svetozar 对机器人将行进的期望距离感兴趣,假设其初始点是从所有好点中等概率选择的。

输入格式

第一行包含两个整数 $n$ 和 $k$ ($3 \le n \le 100, 1 \le k \le n$):Svetozar 邀请的朋友数量以及机器人的参数。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($0 \le a_i < 360 \cdot 10^3, a_i \neq a_j$ 当 $i \neq j$ 时)。这里,$a_i$ 表示从平台中心指向正北的方向与指向 Svetozar 第 $i$ 位朋友的方向之间的逆时针夹角,单位为千分之一度。

输出格式

输出一个实数:期望距离,以平台半径为单位。如果输出结果的绝对误差或相对误差不超过 $10^{-4}$,则视为正确。

样例

样例输入 1

3 1
2023 122023 242023

样例输出 1

0.607986406

样例输入 2

3 2
122023 242023 2023

样例输出 2

1.174556945

样例输入 3

3 3
242023 2023 122023

样例输出 3

1.376646683

样例输入 4

9 9
8 24 43 539 982 4435 39982 44353 99824

样例输出 4

1.046471608

样例输入 5

3 1
998 244 353

样例输出 5

0.002476278

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.