Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/funksiya-uchburchak-ikki-baravar-yuzi

Double area of a triangle

Easy 1000 ms 128 MB 21%
Share

Write a function DoubleArea(x1, y1, x2, y2, x3, y3) that returns twice the area $2S$ of the triangle with vertices $A(x_{1}; y_{1})$, $B(x_{2}; y_{2})$ and $C(x_{3}; y_{3})$:

$$2S = |(x_{2} - x_{1}) * (y_{3} - y_{1}) - (y_{2} - y_{1}) * (x_{3} - x_{1})|$$

Example 1: DoubleArea(0, 0, 4, 0, 0, 3) → 12 — a right triangle with legs $4$ and $3$: $S = 6$.

Example 2: DoubleArea(1, 1, 3, 4, -2, 5) → 17

Write only the function body.

A triangle with vertices A, B, C on the coordinate plane; the function returns twice its area

Input

One line with six integers $x_{1}$, $y_{1}$, $x_{2}$, $y_{2}$, $x_{3}$ and $y_{3}$ — the arguments of the function.

Output

The value returned by the function: an integer.

Note

$-10^{6} \le x_{1}, y_{1}, x_{2}, y_{2}, x_{3}, y_{3} \le 10^{6}$
The three points do not lie on one line.

Examples

Input #1
0 0 4 0 0 3
Output #1
12
Input #2
1 1 3 4 -2 5
Output #2
17

Sign in to submit a solution

Signing up is free and takes a minute.