Polygon Area
From AOJ. Shape / Area. Solve the geometry problem "Polygon Area".
Examples
Input: [0,0,4,0,4,3]
Output: 6
Input: [0,0,4,0,4,3,0,3]
Output: 12
Hints
Core concept: Shoelace formula (Gauss area). Area = ½|∑(x_i·y_{i+1} - x_{i+1}·y_i)|. Cross product of consecutive edge vectors drives it.
Iterate i from 0 to n-1, accumulate x[i]*y[(i+1)%n] - x[(i+1)%n]*y[i]. Take absolute value, divide by 2. Modulo handles wrap-around closure.
Sign flips if vertices given clockwise vs counter-clockwise — always take abs. Formula works for concave polygons too. Use float or long to avoid overflow.
Related Problems
Polygon Area
**From AOJ.** Shape / Area. Solve the geometry problem "Polygon Area".