E. Darts
geometry; probabilities
The night after the graduation ceremony graduate students of German University in Cairo (GUC) are playing darts. As there's no real dart board available, the photographs of members of the GUC upper management are being used.So, n rectangular photos are placed on the wall. They can overlap arbitrary and even coincide. The photos are not necessarily placed horizontally or vertically, they could also be rotated before being pinned to the wall.The score of one dart throw is simply the number of photos the dart went through.Fatma has made a throw but her score was not recorded. She only remembers that she did make it into at least one photo.Assuming that the probability distribution of the throw is equal across the whole wall, what would be the expectation of Fatma's score?
The first line of input contains integer n (1 ≤ n ≤ 500) — the number of photos on the wall. Then follow n lines describing the photos, each containing 8 single-space-separated integers (coordinates of 4 vertices): x1, y1, x2, y2, x3, y3, x4, y4. Each photo is a rectangle with a nonzero area. The coordinates are integers, not exceeding 104 by absolute value. The coordinates of the rectangle are given in either clockwise or counterclockwise order.
Print the expected score of the throw. The answer will be accepted if it has absolute or relative error not exceeding 10 - 6.