#P46. Machining Disc Rotors

Machining Disc Rotors

题目描述

Edward is a worker for Aluminum Cyclic Machinery. His work is to control the mechanical arms to cut out some parts of the mould material. Here is a brief introduction to his work.

Suppose the operation panel for him is a Euclidean plane with the coordinate system. Originally the mould is a disc whose centre coordinates is (0,0)(0,0) and of radius RR. Edward controls nn different mechanical arms to cut out and erase those all of the mould within their affected areas. The affected area of the ii-th mechanical arm is a circle whose centre coordinate is (xi,yi)(x_i,y_i) and of radius rir_i. In order to obtain the highly developed product, it is guaranteed that the affected areas of any two mechanical arms share no intersection and no one has an affected area containing the whole original mould.

Your task is to determine the diameter of the residual mould. Here the diameter of a subset, which may not be convex, over the Euclidean plane is the supremum (i. e. the least upper bound) of distances between every two points in the subset. Here is an illustration of the sample.

输入格式

The input contains several test cases, and the first line contains a positive integer TT indicating the number of test cases which is up to 50005000.

For each test case, the first line contains two integers nn and RR, where 1n1001\le n\le100 and 1R10001\le R\le1000.

The following nn lines describe all mechanical arms controlled by Edward, the ii-th of which contains three integers xi,yix_i,y_i and rir_i describing the affected area of the ii-th mechanical arm, where 1000xi,yi1000-1000\le x_i,y_i\le1000 and 1ri10001\le ri\le1000.

输出格式

For each test case, output a line containing "Case #x: y" (without quotes), where xx is the test case number starting from 11, and yy is the diameter of the remaining area with an absolute or relative error of at most 10910^{-9}. Precisely speaking, assume that your answer is aa and and the jury's answer is bb, your answer will be considered correct if $\frac{\left|a-b\right|}{\max\{1,\left|b\right|\}}\le10^{-9}$, where max{x,y}\max\{x,y\} means the maximum of xx and yy and x\left|x\right| means the absolute value of xx.

1  
3 10  
0 12 10  
11 -6 10  
-11 -6 10
Case #1: 18.611654895000252

题目大意

现在一个以原点为圆心,半径为 RR 的大圆,和 nn 个以 (xi,yi)(x_i,y_i) 为圆心,半径为 rir_i互相的交也互不包含的小圆,问大圆去掉与小圆相交的部分,那剩下的大圆最大直径为多少,其中小圆不会包含大圆。

题目来源

2018-ICPC国际大学生程序设计竞赛-沈阳站 - L题