WOSS Dual Olympiad 2022 Team Round P1: Bobby and His Calculus Test

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Authors:
Problem type

Bobby is in a very sticky situation. His integration test is scheduled for tomorrow but he hasn't studied at all! As such, he decides to bribe his math teacher to delay his math test. However, his math teacher does not accept bribes. Instead, he asks Bobby to solve a math problem for him. He gives him three coordinates (x_1, y_1), (x_2, y_2), and (x_3, y_3). These represent the coordinates of the points of a triangle. His teacher asks him to solve for the area of the triangle. You need to write a program to help him!

Helpful Formulas:

  • The distance between two points (x_a, y_a) and (x_b, y_b) is given by the formula: \sqrt{(x_a-x_b)^2+(y_a-y_b)^2}.
  • If A, B, C are the side lengths of a triangle, its area is given by Heron's formula: \sqrt{S(S-A)(S-B)(S-C)}, where S = \frac{A+B+C}{2}.

Constraints

-10^3 \le x, y \le 10^3

Subtask 1 [20%]

The points are guaranteed to form a right triangle (i.e. a triangle containing a 90 degree angle), such that two of the sides are parallel to the x and y axis respectively.

Subtask 2 [80%]

No additional constraints.

Input Specification

The input consists of three lines: each line contains two space-separated integers, x and y, representing one of the coordinates of the triangle.

Output Specification

Output should consist of a single floating point (decimal) value, giving the area of the triangle. Since there is a possibility of decimal values, the answer will be marked as correct if it has an absolute or relative error of at most 10^{-5}.

Sample Input

0 0
6 0
0 7

Sample Output

21

Explanation of Sample

It can be shown using Heron's formula that the area of the triangle is 21 units^2.


Comments

There are no comments at the moment.