Wesley's Anger Contest 2 Problem 4 - The Ninth Triangle of the Underworld

View as PDF

Submit solution


Points: 20
Time limit: 0.3s
Java 1.0s
Python 1.0s
Memory limit: 256M

Authors:
Problem types

At your neighbourhood Halloween party, appropriately named The Ninth Triangle of the Underworld, you've decided to play a fun game! Two witch hats are placed on conveyor belts moving in opposite directions. For simplicity, we can imagine the witch hats as triangles, with their bases on the same line parallel to the x-axis, and that the witch hats will continue moving in opposite directions for eternity.

You are asked to throw a ball at the witch hats and will win a prize if you hit either one of them. To make your life more difficult, you will only be told the side lengths of the triangles and will not be told the orientation of the witch hats. In addition, you will not be told when to throw the ball at the targets.

You want to know what is the smallest target area you could possibly be facing when you throw the ball. The target area is the area of the union of the two triangles at their current locations.

Constraints

1 \le a, b, c, d, e, f \le 10^8
a, b, c, d, e, f \in \mathbb{Z}
a < b + c
b < a + c
c < a + b
d < e + f
e < d + f
f < d + e

Input Specification

The first line of input contains 3 integers, a, b, c, the side lengths of the first triangle representing the first witch hat.

The second line of input contains 3 integers, d, e, f, the side lengths of the second triangle representing the second witch hat.

Output Specification

This problem is graded with a custom checker.

Output, on a single line, the smallest target area you could possibly be facing when you throw the ball at the witch hats. Ensure this line is terminated with a \n character and has no leading nor trailing spaces.

Your answer will be considered correct if it has an absolute or relative error of at most 10^{-8} from the reference solution. It is guaranteed that the absolute or relative error of the reference solution is much smaller than 10^{-8} from the optimal solution.

Sample Input

8 5 5
6 6 6

Sample Output

16.9112382237

Comments


  • 1
    harry7557558  commented on Jan. 30, 2020, 4:05 p.m.

    I used numerical method in C++11 and get AC, but get WA in test case 3 after adding #pragma GCC optimize "Ofast" to enable optimization.


    • 4
      wleung_bvg  commented on Jan. 30, 2020, 8:12 p.m.

      Unfortunately, C++ will sometimes try to take shortcuts when optimizing code. This can sometimes result in floating point inaccuracies.