QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 512 MB Total points: 100

#7229. 直线

Statistics

给定平面上的 $n$ 个不同的点 $a_1, \dots, a_n$。对于每一对 $i, j$ ($i < j$),考虑经过点 $a_i$ 和 $a_j$ 的直线(记为 $L_{i,j}$)。$A_{i,j}$ 是从水平线到 $L_{i,j}$ 的弧度角,方向为逆时针,满足 $0 \le A_{i,j} < \pi$。

令 $p_1, \dots, p_{\frac{n(n-1)}{2}}$ 为所有 $A_{i,j}$ 按升序排列后的数组。你的任务是找到 $p$ 的中位数。

长度为 $x$ 的数组的中位数定义为:若 $x$ 为奇数,则为第 $\lfloor \frac{x}{2} \rfloor + 1$ 个元素;若 $x$ 为偶数,则为第 $\lfloor \frac{x}{2} \rfloor$ 个元素与第 $\lfloor \frac{x}{2} \rfloor + 1$ 个元素的平均值。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 10^5$),表示点的数量。

接下来 $n$ 行包含这些点的坐标。 第 $i$ 行包含两个整数 $x_i$ 和 $y_i$ ($-10^9 \le x_i, y_i \le 10^9$),表示点 $a_i$ 的坐标。

保证所有点互不相同。

输出格式

输出这些角度的中位数,要求绝对误差或相对误差不超过 $10^{-9}$。

样例

样例输入 1

3
0 0
0 1
1 0

样例输出 1

1.5707963268949

样例输入 2

4
0 0
0 1
1 0
1 1

样例输出 2

1.1780972451717

样例输入 3

3
0 0
0 1000000000
1 0

样例输出 3

1.5707963267949

样例输入 4

3
0 0
1 0
2 0

样例输出 4

0

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#140EditorialOpen题解jiangly2025-12-12 23:30:50View

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.