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

View as PDF

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

Authors:
Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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 -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.

#### Input Specification

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

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

#### Output Specification

This problem is graded with an 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 from the reference solution. It is guaranteed that the absolute or relative error of the reference solution is much smaller than from the optimal solution.

#### Sample Input

8 5 5
6 6 6

#### Sample Output

16.9112382237

## Comments

• commented on Jan. 30, 2020, 11:05 a.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.

• commented on Jan. 30, 2020, 3:12 p.m.

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