Statistics

Problem Statement for "VertexMove"

Problem Statement

You are given three points in the plane. Currently, these points are the vertices of a triangle with side lengths a, b, and c meters.

You can pick any one of the three points and move it by at most 1 meter in any direction. The other two vertices remain in their places.

After you finish moving the point, you look at the triangle they now define. What is the largest possible area of this new triangle?

Definition

Class:
VertexMove
Method:
largestTriangleArea
Parameters:
int, int, int
Returns:
double
Method signature:
double largestTriangleArea(int a, int b, int c)
(be sure your method is public)

Notes

  • Answers with an absolute or a relative error up to 1e-9 will be accepted.

Constraints

  • Each of a, b, c is an integer between 1 and 1000, inclusive.
  • It is guaranteed that the lengths a, b, c satisfy the triangle inequality. (I.e., the three lengths define a valid triangle with a positive area.)

Examples

  1. 3

    4

    5

    Returns: 8.5

    If we have a coordinate system in the plane, the three points may be located at (0, 0), (0, 3), and (4, 0). If this is the case, the optimal solution is to take the point (0, 0) and move it to (-0.6, -0.8). This is a move by exactly 1 meter, and it produces a triangle with the area 8.5 square meters.

  2. 10

    10

    10

    Returns: 48.30127018922193

  3. 12

    13

    16

    Returns: 84.68727078205352

  4. 324

    534

    432

    Returns: 70232.45529759668

  5. 11

    12

    13

    Returns: 67.98170459575759

  6. 1

    1

    1

    Returns: 0.9330127018922193

  7. 1

    3

    3

    Returns: 2.979019945774904

  8. 1000

    999

    670

    Returns: 315964.9437535611

  9. 461

    613

    334

    Returns: 76201.1258966997

  10. 123

    88

    66

    Returns: 2865.031422599005

  11. 900

    540

    630

    Returns: 167815.97436456432

  12. 6

    5

    4

    Returns: 12.921567416492215

  13. 18

    14

    6

    Returns: 44.14256678161116

  14. 25

    15

    15

    Returns: 116.14452469860625

  15. 187

    45

    166

    Returns: 3577.149810184715

  16. 725

    411

    601

    Returns: 123862.88296372809

  17. 199

    192

    225

    Returns: 18091.132206038368


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: