eolymp
bolt
Try our new interface for solving problems
Problems

Pollution Solution

Pollution Solution

As an employee of Aqueous Contaminate Management, you must monitor the pollution that gets dumped (sometimes accidentally, sometimes purposefully) into rivers, lakes and oceans. One of your jobs is to measure the impact of the pollution on various ecosystems in the water such as coral reefs, spawning grounds, and so on. \includegraphics{https://static.e-olymp.com/content/a1/a19be1c11b6bb7a9e309d0c17f925c4d8d24ca71.jpg} \textit{\textbf{Figure 1}}: Illustration of Sample Input 1. The model you use in your analysis is illustrated in \textit{\textbf{Figure 1}}. The shoreline (the horizontal line in the figure) lies on the x-axis with the source of the pollution located at the origin \textbf{(0, 0)}. The spread of the pollution into the water is represented by the semicircle, and the polygon represents the ecosystem of concern. You must determine the area of the ecosystem that is contaminated, represented by the dark blue region in the figure. \InputFile The input consists of a single test case. A test case starts with a line containing two integers \textbf{n} and \textbf{r}, where \textbf{3} ≤ \textbf{n} ≤ \textbf{100} is the number of vertices in the polygon and \textbf{1} ≤ \textbf{r} ≤ \textbf{1000} is the radius of the pollution field. This is followed by \textbf{n}lines, each containing two integers \textbf{x_i}, \textbf{y_i}, giving the coordinates of the polygon vertices in counter-clockwise order, where \textbf{-1500} ≤ \textbf{x_i} ≤ \textbf{1500} and \textbf{0} ≤ \textbf{y_i} ≤ \textbf{1500}. The polygon does not self-intersect or touch itself. No vertex lies on the circle boundary. \OutputFile Display the area of the polygon that falls within the semicircle centered at the origin with radius \textbf{r}. Give the result with an absolute error of at most \textbf{10^\{-3\}}.
Time limit 1 second
Memory limit 256 MiB
Input example #1
6 10
-8 2
8 2
8 14
0 14
0 6
-8 14
Output example #1
101.576437872
Source ACM-ICPC World Finals 2013