Məsələlər
Area Folding
Area Folding
You are given one polygonal line, which is a collection of line segments. Your task is to calculate the sum of areas enclosed by the polygonal line.
A point is defined to be "\textbf{enclosed}" if and only if the point is unreachable without crossing at least one line segment from the point at infinity.
\InputFile
The first line contains one integers \textbf{N} (\textbf{2} ≤ \textbf{N} ≤ \textbf{100}). \textbf{N} is the number of segments.
Each of the following \textbf{N} lines consists of two integers \textbf{X_\{i \}}and \textbf{Y_i (-10^5 }≤ \textbf{X_i, Y_i }≤ \textbf{10^5, 1 }≤ \textbf{i }≤ \textbf{N) }which represents a vertex. A polygonal line is the segments which connect (\textbf{X_j}, \textbf{Y_j}) and (\textbf{X_\{j+1\}}, \textbf{Y_\{j+1\}}) ((\textbf{X_j}, \textbf{Y_j}) ≠ (\textbf{X_\{j+1\}}, \textbf{Y_\{j+1\}}), \textbf{1} ≤ \textbf{j} ≤ \textbf{N−1}). The distance between a segment \textbf{S_j} and all vertices except the end points on segment \textbf{S_j} is guaranteed to be greater than \textbf{0.01}.
\OutputFile
Output the answer in a line. The answer may be printed with an arbitrary number of decimal digits, but may not contain an absolute or relative error greater than or equal to \textbf{10^\{−6\}}.
Giriş verilənləri #1
5 0 0 1 1 1 0 0 1 0 0
Çıxış verilənləri #1
0.5