QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#15284. 线段到线段距离

Statistics

给定平面上四个整点 $A, B, C, D$,你需要求线段 $AB$ 到线段 $CD$ 的距离。线段 $AB$, $CD$ 均可能会退化为一个点。

输入格式

每个测试点中包含多组测试数据。

输入的第一行包含一个整数 $T$,表示数据组数。对于每组数据:

输入只有一行,包含 8 个整数 $x_A, y_A, x_B, y_B, x_C, y_C, x_D, y_D$,分别描述三个点的坐标。

输出格式

对于每组测试数据,输出一行一个实数,表示最短距离。要求相对误差或绝对误差不超过 $10^{-9}$。

样例数据

样例输入

6
0 0 1 1 1 0 2 1
0 0 1 1 2 2 3 3
0 0 0 100 100 0 200 300
0 0 0 100 50 50 100 50
-1000000000 -1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000 1000000000
998 244 353 114 514 19 19 810

样例输出

0.7071067812
1.4142135624
100.0000000000
50.0000000000
2000000000.0000000000
0.0000000000

子任务

对于所有数据,$1 \le T \le 10^5$,点的每一维坐标为 $[-10^9, 10^9]$ 中的整数。点的坐标可能重合。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.