QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#9083. 两只蚂蚁

统计

有两只蚂蚁降落在无限大的地面上,地面上有两根巧克力棒,一根白色,一根黑色。然而,它们不知道彼此的准确位置。

“你在哪里?”蚂蚁 A 喊道。

“我不知道。但从我的视角看,我只能看到白色的那根棒子!”蚂蚁 B 回答道。

“好吧,我无法确定你的准确位置,但我知道你可能在哪里!”蚂蚁 A 说。

如果两根棒子可以被视为不包含端点且最多只有一个公共点的线段,你能猜出蚂蚁 B 可能在哪里吗?请计算出该区域的总面积。

输入格式

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

接下来有 $T$ 行,每行包含一个测试用例。

对于每个测试用例,有八个整数 $x_w, y_w, X_w, Y_w, x_b, y_b, X_b, Y_b$,取值范围在 $[-1000, 1000]$ 之间。白色棒子由其两个端点位置 $(x_w, y_w), (X_w, Y_w)$ 表示,黑色棒子由其两个端点位置 $(x_b, y_b), (X_b, Y_b)$ 表示。

输出格式

精确打印 $T$ 行。

对于每一行,请先输出 Case d:($d$ 表示测试用例的序号),然后输出答案。答案的绝对误差应小于 $10^{-6}$。如果该区域是无限大的,则输出 inf

样例

输入格式 1

3
0 0 0 1 0 0 1 0
0 0 1 0 0 1 0 -1
1 1 1 2 0 0 0 3

输出格式 1

Case 1: inf
Case 2: 0.000
Case 3: 0.2500000000

说明

样例 3:

只有区域 S 满足要求,其总面积为 0.25。

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.