Məsələlər
Encircling Circles
Encircling Circles
You are given a set of circles \textbf{C} of a variety of radii (radiuses) placed at a variety of positions, possibly overlapping one another. Given a circle with radius \textbf{r}, that circle may be placed so that it encircles all of the circles in the set \textbf{C} if \textbf{r} is large enough.
There may be more than one possible position of the circle of radius \textbf{r} to encircle all the member circles of \textbf{C}. We de ne the region \textbf{U} as the union of the areas of encircling circles at all such positions. In other words, for each point in \textbf{U}, there exists a circle of radius \textbf{r} that encircles that point and all the members of \textbf{C}. Your task is to calculate the length of the periphery of that region \textbf{U}.
\textit{\textbf{Figure 1}}. shows an example of the set of circles \textbf{C} and the region \textbf{U}. In the gure, three circles contained in \textbf{C} are expressed by circles of solid circumference, some possible positions of the encircling circles are expressed by circles of dashed circumference, and the area \textbf{U} is expressed by a thick dashed closed curve.
\includegraphics{https://static.e-olymp.com/content/34/345843c0fd2310bffa335efd4cfe8f78ab5c82ed.jpg}
\textit{\textbf{Figure 1.}} Example of the Circle Set
\InputFile
The input is a sequence of datasets. The number of datasets is less than \textbf{100}.
Each dataset is formatted as follows.
\textbf{n r x_1 y_1 r_1 x_2 y_2 r_2 . . . x_n y_n r_n}
The first line of a dataset contains two positive integers, \textbf{n} and \textbf{r}, separated by a single space. \textbf{n} means the number of the circles in the set \textbf{C} and does not exceed \textbf{100}. \textbf{r} means the radius of the encircling circle and does not exceed \textbf{1000}.
Each of the \textbf{n} lines following the rst line contains three integers separated by a single space. (\textbf{x_i}, \textbf{y_i}) means the center position of the \textbf{i}^th circle of the set \textbf{C} and \textbf{r_i} means its radius.
You may assume -\textbf{500} ≤ \textbf{x_i} ≤ \textbf{500}, -\textbf{500} ≤ \textbf{y_i} ≤ \textbf{500}, and \textbf{1} ≤ \textbf{r_i} ≤ \textbf{500}.
The end of the input is indicated by a line containing two zeros separated by a single space.
\OutputFile
For each dataset, output a line containing a decimal fraction which means the length of the periphery (circumferential length) of the region \textbf{U}.
The output should not contain an error greater than \textbf{0.01}. You can assume that, when \textbf{r} changes by \textbf{ϵ} (|\textbf{ϵ}| < \textbf{0.0000001}), the length of the periphery of the region \textbf{U} will not change more than \textbf{0.001}.
If \textbf{r} is too small to cover all of the circles in \textbf{C}, output a line containing only \textbf{0.0}.
No other characters should be contained in the output.
\includegraphics{https://static.e-olymp.com/content/35/35cd782d4a64cfbe626f0635cc628e323184c2ed.jpg}
\textit{\textbf{Figure 2}}. Last Dataset of the Sample Input
Giriş verilənləri #1
1 10 5 5 7 2 12 5 5 7 8 6 3 3 10 3 11 2 2 1 1 2 16 3 3 15 -5 2 5 9 2 9 5 8 6 3 38 -25 -10 8 30 5 7 -3 35 11 3 39 -25 -10 8 30 5 7 -3 35 11 3 800 -400 400 2 300 300 1 300 302 1 3 800 400 -400 2 300 300 1 307 300 3 8 147 130 80 12 130 -40 12 -110 80 12 -110 -40 12 70 140 12 70 -100 12 -50 140 12 -50 -100 12 3 493 345 154 10 291 111 75 -275 -301 46 4 55 54 0 1 40 30 5 27 36 10 0 48 7 3 30 0 3 3 -3 0 4 400 0 3 3 7 2 3 2 -5 -4 2 -4 3 2 3 10 -5 -4 5 2 3 5 -4 3 5 4 6 4 6 1 5 5 1 1 7 1 0 1 1 3 493 345 154 10 291 111 75 -275 -301 46 5 20 -9 12 5 0 15 5 3 -3 3 12 9 5 -12 9 5 0 0
Çıxış verilənləri #1
81.68140899333463 106.81415022205297 74.11215318612639 108.92086846105579 0.0 254.85616536128433 8576.936716409238 8569.462129048667 929.1977057481128 4181.124698202453 505.09134735536804 0.0 46.82023824234038 65.66979416387915 50.990642291793506 4181.124698202453 158.87951420768937