Loop of Chocolate
시간 제한2초메모리 제한1024 MB
같은 크기의 구 n개가 하나의 닫힌 고리를 이루며 이웃한 구끼리만 교차할 때, 구들의 합집합 부피를 구한다.
문제
Let’s make sweets of a fancy shape that is a loop of chocolate.

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.
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{align\*}\&n \\, r \\\ & x\_1 \\, y\_1 \\, z\_1 \\\ & \vdots \\\ & x\_n \\, y\_n \\, z\_n \end{align\*}
and are integers. is the number of spheres (). All the spheres has 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 -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 .

