eolymp
bolt
Try our new interface for solving problems

Light

Santa Claus Petrovich moved to a new hut. It consists of only one room. Its floor has the form of a simple polygon (not necessarily convex) with N vertices. It was dark in the hut at first, but then Petrovich hung a lamp at the point with projection (\textbf{X_0}, \textbf{Y_0}). Which area of the room is illuminated by the lamp? \InputFile The first line contains the coordinates of the lamp (\textbf{X_0}, \textbf{Y_0}). You may regard the lamp as a material point. The second line contains the integer \textbf{3} ≤ \textbf{N} ≤ \textbf{50000}. In the next \textbf{N} lines there are coordinates (\textbf{X_i}, \textbf{Y_i}) of vertices of the \textbf{N}-gon. The vertices are given in the counter-clockwise order. All the coordinates are given as pairs of real numbers separated with a space, \textbf{0} ≤ \textbf{X_i}, \textbf{Y_i} ≤ \textbf{1000}. The coordinates contain not more than four fractional digits. It is guaranteed that the lamp is strictly inside the room. \OutputFile Output the area S of the illuminated part of the room. The area must be given with accuracy of at least two fractional digits.
Time limit 3 seconds
Memory limit 32 MiB
Input example #1
1.0 1.0
6
0 0 
3 0
3 2
2 2
2 3
0 3
Output example #1
8.00
Author Dmitry Ivankov
Source Ural SU Contest. Petrozavodsk Winter Session, January 2006