Going to the Moon

시간 제한1초메모리 제한1024 MB

요약
중심 C, 반지름 r인 원을 지나거나 접하는 A에서 B까지의 최단 경로 길이를 구한다.
난이도

보통10점 중 4점

유형
기하, 수학
정답자
아직 제출이 없습니다

문제

Alice and Bob are playing a game in the sand outside their mansion. A circle representing the Moon is drawn somewhere, and they each also pick a place to stand (inside, on the edge, or outside the Moon). The goal of the game is that one of the players runs to the other as fast as possible, while also touching the Moon during the run.

Given the positions of the Moon, Alice, and Bob, find the length of the shortest path that starts at one of the players, touches (or crosses) the edge or the interior of the Moon, and ends at the position of the other player.

입력

The first line contains an integer TT, the number of test cases. It's followed by TT lines, each containing 7 space-separated integers x_Ax\_A, y_Ay\_A, x_Bx\_B, y_By\_B, x_Cx\_C, y_Cy\_C, rr, representing coordinates of Alice, A=(x_A,y_A)A = (x\_A, y\_A), Bob, B=(x_B,y_B)B = (x\_B, y\_B), the center of the circle, C=(x_C,y_C)C = (x\_C, y\_C), and its radius rr.

출력

For each test case output a single decimal number representing the length of the shortest path from AA to BB that also touches at least one point inside or on the edge of a circle with the center CC and radius rr. The solution will be considered correct if the relative or absolute error compared to the official solution is within 10−610^{-6}.

제한

  • 1≤T≤1031 \leq T \leq 10^3
  • −103≤x_A,y_A,x_B,y_B,x_C,y_C≤103-10^3 \leq x\_A, y\_A, x\_B, y\_B, x\_C, y\_C \leq 10^3
  • 0≤r≤1030 \leq r \leq 10^3

힌트

The solution for the first test case is shown in the picture.

예제1

  1. 예제 1

    입력
    2
    0 0 2 0 -1 2 1
    5 0 3 0 2 0 2
    
    예상 출력
    3.9451754612261913
    2