eolymp
bolt
Try our new interface for solving problems
Problems

The Red Gem

The Red Gem

\includegraphics{https://static.e-olymp.com/content/6a/6a4b89e158f77560de38064677592f0b018e1627.jpg} In circle land, in the museum of circles, a grand red circular gem is on display. The curator has decided to spice up the display, and has placed the gem on a purple circular platform, along with mundane orange circular gems. Starved citizens of circle land (points) have flocked to see the grand exhibit of the exquisite red gem. They cannot step on the purple exhibit floor, but can only stand on the circumference. Unfortunately, the mundane orange gems block the view of the exquisite red gem. Please help the museum folks determine the proportion of the circumference of the purple platform from which all of the red gem is visible, completely unobstructed by the orange gems. \InputFile There will be several test cases in the input. Each test case will begin with a line with five integers: \textbf{n p x y r} Where \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{100}) is the number of orange circles, \textbf{p} (\textbf{10} ≤ \textbf{p} ≤ \textbf{1000}) is the radius of the purple platform, (\textbf{x},\textbf{y}) is the center of the red gem relative to the center of the purple platform (\textbf{-1000} ≤ \textbf{x}, \textbf{y} ≤ \textbf{1000}), and \textbf{r} (\textbf{0} < \textbf{r} ≤\textbf{1000}) is the radius of the red gem. The red gem is guaranteed to lie fully on the purple platform. No part of the red gem will extend past the purple platform. On each of the next \textbf{n} lines will be three integers: \textbf{x y r} which represent the (\textbf{x}, \textbf{y}) center (\textbf{-1000} ≤ \textbf{x}, \textbf{y} ≤ \textbf{1000}) relative to the center of the purple platform, and radius \textbf{r} (\textbf{0}< \textbf{r} ≤ \textbf{1000}) of each orange gem. As with the red gem, each orange gem is guaranteed to lie entirely on the purple platform. The orange gems will not overlap the red gem, and they will not overlap each other. The input will end with a line with \textbf{5} \textbf{0}s. \OutputFile For each test case, output a single floating point number on its own line, indicating the proportion of the perimeter of the purple platform where all of the red gem is visible. This result should be between \textbf{0} and \textbf{1} (inclusive). Output this number with exactly \textbf{4} decimal places of accuracy, with standard \textbf{5} up / \textbf{4} down rounding (e.g. \textbf{2.12344} rounds to\textbf{2.1234}, \textbf{2.12345} rounds to \textbf{2.1235}). Output each number on its own line, with no spaces, and do not print any blank lines between answers.
Time limit 1 second
Memory limit 32 MiB
Input example #1
4 10 0 0 1
5 0 2
0 5 2
-5 0 2
0 -5 2
0 0 0 0 0
Output example #1
0.3082
Source The University of Chicago Invitational Programming Contest 2012 15 April 2012