Cutting Diamonds

Ellipsoid is the 3D counterpart of a 2D ellipse. The ellipse x2 + y2 = 1 is centered at (0, 0) and cuts the x a2 b2 and y axes at the points (±a, 0) and (0, ±b) respectively. In the same way the ellipsoid x2 + y2 + z2 = 1 a2 b2 c2 is centered at (0,0,0) and cuts the x, y and z axes at the points (±a,0,0), (0,±b,0) and (0,0,±c) respectively. A factory produces colorful artificial diamonds having the shape of an ellipsoid. Each diamond is transported in a separate box made of very thin, transparent, heat resistant material. The box has regular shape: it has 6 rectangular faces; each face is perpendicular to the adjacent faces. As the material of the box is more precious than the diamond it carries, its size is kept as small as possible. As a result, when packed in the box, the diamond touches each of 6 faces of the box at the points (±a, 0, 0), (0, ±b, 0) and (0, 0, ±c) (assuming the diamond has its center at the origin and its axes along the coordinate systems axes. Due to some technical problems, some of the boxes made in the last few weeks have become shorter/longer than expected in either length or width or height. So, each diamond has to be cut smaller to fit in its box. The factory has decided to cut off the side that exceeds its box’s corresponding dimension. The effort needed to cut a diamond is proportional to the area of the plane on the diamond along which the cut is made. You have been appointed to calculate cut area (cross section) of each diamond. Input Input consists of several test cases and terminated by EOF. Each test case consists of 6 positive integers (< 20) separated by space(s) in a single line: the lengths of the box along x, y and z axes, followed by the lengths of the diamond along x, y and z axes when the diamond’s axes are aligned with the coordinate axes. Neither the diamond nor the box is to be rotated to make a better fit. At most one cut is needed for each diamond. Output For each set, print the set number (1, 2, . . .) in a line, followed by the area of the plane through which the cut is made in another line. The area should be printed with 6 digits after the decimal point. Sample Input 764864 488888 Sample Output Set #1 8.246681 Set #2 50.265482