#P2785. Calculate Magnetic Flux
Calculate Magnetic Flux
Calculate Magnetic Flux
HansBug is presented with a strange magnetic field in the form of a polygon. The polygon is described by a sequence of points representing its vertices in order. The magnetic flux in this context is defined as the area of the polygon. You can compute the area using the shoelace formula:
$$\text{Area} = \frac{1}{2} \left| \sum_{i=1}^{N} \left( x_i y_{i+1} - x_{i+1} y_i \right) \right|, $$where and . Your task is to calculate and output the magnetic flux (i.e. the area) of the polygon.
inputFormat
The first line contains an integer (), the number of vertices of the polygon. Each of the following lines contains two integers and (), which are the coordinates of the vertices given in order.
outputFormat
Output a single number, which is the magnetic flux (area) of the polygon. Print the result with one digit after the decimal point.
sample
4
0 0
4 0
4 3
0 3
12.0
</p>