QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#15283. Distance from a Point to a Line Segment

Estadísticas

Given three integer points $A, B, C$ on a plane, you need to find the distance from point $C$ to the line segment $AB$. The line segment $AB$ may degenerate into a single point.

Input

Each test case contains multiple test data.

The first line of the input contains an integer $T$, representing the number of test cases. For each test case:

The input consists of a single line containing 6 integers $x_A, y_A, x_B, y_B, x_C, y_C$, describing the coordinates of the three points respectively.

Output

For each test case, output a single real number representing the shortest distance. The relative or absolute error must not exceed $10^{-9}$.

Examples

Input 1

5
0 0 1 1 2 2
0 0 0 1 1 1
0 0 0 1 2 2
0 0 0 0 1 4
-1000000000 -1000000000 1000000000 1000000000 0 0

Output 1

1.4142135624
1.0000000000
2.2360679775
4.1231056256
0.0000000000

Constraints

For all data, $1 \le T \le 10^5$, and each coordinate of the points is an integer in the range $[-10^9, 10^9]$. The coordinates of the points may coincide.

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.