#P14853. [ICPC 2021 Yokohama R] Loop of Chocolate
[ICPC 2021 Yokohama R] Loop of Chocolate
题目描述
Let’s make sweets of a fancy shape that is a loop of chocolate.
:::align{center}

Figure A.1. A loop of chocolate formed by a union of six spheres :::
The shape of a loop is formed by a union of a number of spheres of the same size, where every sphere intersects with exactly two others.
:::align{center}

(a) Union of four spheres (b) Four intersections of the four spheres in (a)
Figure A.2. A loop of chocolate formed by a union of four spheres :::
Your job is to write a program that, for given the size and the positions of spheres, computes the total volume of the union of the spheres, i.e., the amount of chocolate required for filling the loop formed by the union.
[Hints] Two spheres of the same radius intersect each other when the distance between their centers, , is less than . The volume of the intersection is known to be
The volume of the sphere of radius is .
输入格式
The input consists of a single test case of the following format.
$$\begin{aligned} &n\ r \\ &x_1\ y_1\ z_1 \\ &\vdots \\ &x_n\ y_n\ z_n \end{aligned}$$and are integers. is the number of spheres (). All the spheres have the same radius (). indicates the coordinates of the center of the -th sphere (). All of , , and are integers between and , inclusive.
The -th and the -th spheres intersect each other for . The 1-th and the -th spheres also intersect. No other pairs of spheres intersect.
输出格式
Output in a line the volume of the union of the spheres. Relative error of the output should be within .
6 9
20 0 10
20 10 0
10 20 0
0 20 10
0 10 20
10 0 20
17149.528141
4 12
10 10 0
10 -10 0
-10 -10 0
-10 10 0
27813.56696
6 9
23 3 13
20 10 0
10 20 0
3 23 13
0 10 20
10 0 20
17470.837758
4 2
0 0 0
3 0 0
3 3 0
0 3 0
122.52211349
8 70
100 100 0
0 100 0
-100 100 0
-100 0 0
-100 -100 0
0 -100 0
100 -100 0
100 0 0
10220648.1