QOJ.ac

QOJ

実行時間制限: 5.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#7071. 最大化比率

統計

在几何学中,凸多边形是一种简单多边形(不自交),其边界上任意两点之间的线段都不会落在多边形外部。等价地,它是一个内部为凸集的简单多边形。

给定平面上的 $n$ 个不同点,你可以绘制一些线段,使得:

  • 至少绘制了一条线段。
  • 每条线段的长度均为正且有限。
  • 每条线段的端点都属于给定的点集。
  • 对于任意两条线段,它们要么共享一个端点,要么没有交点。
  • 所有线段构成一个凸多边形。

设该多边形的面积为 $A$,所有线段长度的平方和为 $B$。你的任务是最大化 $A$ 与 $B$ 的比值。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 10$),表示测试用例的数量。接下来是 $T$ 个测试用例。

对于每个测试用例:第一行包含一个整数 $n$ ($3 \le n \le 500$),表示给定点的数量。接下来的 $n$ 行,每行包含两个整数 $x$ 和 $y$ ($-10^4 \le x, y \le 10^4$),表示一个点 $(x, y)$。

对于单个测试用例中的所有点,保证没有两个点是相同的,且没有三个点共线。同时保证所有测试用例中 $n$ 的总和不超过 $500$。

输出格式

对于每个测试用例,输出 $A$ 与 $B$ 的最大比值,占一行。如果你的答案的绝对误差或相对误差不超过 $10^{-9}$,则视为正确。

形式化地说,假设你的输出为 $a$,标准答案为 $b$。当且仅当 $\frac{|a-b|}{\max(1,|b|)} \le 10^{-9}$ 时,你的输出被接受。

样例

样例输入 1

2
4
0 0
0 5
5 5
5 0
4
0 0
0 5
5 0
2 2

样例输出 1

0.250000000000000
0.125000000000000

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#285EditorialOpen题解jiangly2025-12-14 06:52:13View

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.