QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#3772. Distance from a point to a circular arc

Estadísticas

Given a point $P$ and a circular arc (a portion of a circle), your task is to calculate the shortest distance from $P$ to the arc. In other words, you need to find a point on the arc such that the distance to $P$ is minimized.

Tip: Please try to use an exact algorithm. In comparison, approximate algorithms are harder to pass the test data for this problem.

Input

The input contains up to $10000$ test cases. Each test case contains $8$ integers $x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p$. The starting point of the arc is $A(x_1, y_1)$, it passes through point $B(x_2, y_2)$, and the ending point is $C(x_3, y_3)$. The position of point $P$ is $(x_p, y_p)$. It is guaranteed that $A, B, C$ are distinct and not collinear. The absolute values of the coordinates of all the above points do not exceed $20$.

Output

For each test case, output the test case number and the distance from $P$ to the arc, rounded to three decimal places. Your output may have an error of at most $0.001$ compared to the standard output.

Examples

Input 1

0 0 1 1 2 0 1 -1
3 4 0 5 -3 4 0 1

Output 1

Case 1: 1.414
Case 2: 4.000

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.