Arc and Point

Given a circular arc (i.e. part of the circumference of a circle) and a point P, your task is to calculate the shortest distance between them. That means, you should find a point on the arc, whose distance to P is minimized. Attention: Try to use exact algorithms. Approximation algorithms are harder to pass the judge data. Input There will be at most 10000 test cases. Each case contains 8 integers x1, y1, x2, y2, x3, y3, xp, yp. The arc starts from A(x1, y1), goes through B(x2, y2) and ends at C(x3, y3). The point is located at (xp, yp). It is guaranteed that A, B, C are different points and will not be collinear. The absolute values of all coordinates are not greater than 20. Output For each test case, print the case number and the distance, to three decimal places. Absolute error of 0.001 is allowed. Sample Input 0 0 1 1 2 0 1 -1 3 4 0 5 -3 4 0 1 Sample Output Case 1: 1.414 Case 2: 4.000