#B3638. Triangle Area Calculation

    ID: 11297 Type: Default 1000ms 256MiB

Triangle Area Calculation

Triangle Area Calculation

Given three integer coordinate points A, B, and C in a 2D Cartesian coordinate system, calculate the area of the triangle formed by these points.

You can use the determinant formula:

\(\text{Area} = \frac{1}{2} \big|x_1(y_2-y_3) + x_2(y_3-y_1) + x_3(y_1-y_2)\big|\)

Note: The input data guarantees that the final answer is an integer. If you use floating point arithmetic in your calculations, please round your answer to the nearest integer using standard rounding rules.

In addition, here are a couple of useful formulas:

  • Distance formula: For points \((x_1, y_1)\) and \((x_2, y_2)\), the distance is \(\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}\).
  • Heron's formula: For a triangle with side lengths \(a\), \(b\), and \(c\), and semiperimeter \(s=\frac{a+b+c}{2}\), the area is \(\sqrt{s(s-a)(s-b)(s-c)}\).

inputFormat

The input consists of three lines. Each line contains two space-separated integers representing the x and y coordinates of a point. The points represent A, B, and C respectively.

outputFormat

Output a single integer which is the area of the triangle formed by the three points.

sample

0 0
0 2
2 0
2