Statistics

Problem Statement for "ThreeTrees"

Problem Statement

You are looking to plant a new tree somewhere in your field, which 10 meters wide and 10 meters long. The must be planted at a location that is at least distance away from where any other tree is planted. You are given the location of any other trees in int[]s x and y, where (x[i], y[i]) indicates the location of the i-th tree.

Calculate the total area in which it would be safe to plant the new tree.

Definition

Class:
ThreeTrees
Method:
area
Parameters:
int[], int[], int
Returns:
double
Method signature:
double area(int[] x, int[] y, int distance)
(be sure your method is public)

Notes

  • Your return value must be within 1e-6 absolute or relative error to be considered correct.

Constraints

  • x will have between 0 and 3 elements, inclusive.
  • x and y will have the same number of elements.
  • Each element of x will be between 0 and 10, inclusive.
  • Each element of y will be between 0 and 10, inclusive.
  • distance will be between 0 and 20, inclusive.

Examples

  1. {5}

    {5}

    5

    Returns: 21.460183689207042

    There's a circle of radius 5, centered right in the center of the field, in which we cannot plant the tree. Thus our answer is 100 - pi * 5^2.

  2. {2, 8}

    {2, 8}

    2

    Returns: 74.86725878970901

    Here, there's two circles of radius two that are not available, so we calculate 100 - 2 * pi * 2^2.

  3. {0, 1, 5}

    {0, 0, 3}

    6

    Returns: 17.95288785134835

    Three trees, and whole lot of area that isn't suitable.

  4. {0}

    {0}

    20

    Returns: 0.0

    In a 10x10 field with even a single tree already planted, there's nowhere to put another without being too close to the existing tree.

  5. {1, 8, 7}

    {1, 9, 2}

    4

    Returns: 23.73397466186816

  6. {2, 4, 2}

    {2, 4, 4}

    2

    Returns: 72.63914492916592

  7. {2, 4, 2}

    {6, 4, 4}

    0

    Returns: 100.0

  8. {2, 2, 9}

    {4, 1, 9}

    7

    Returns: 2.0716576703716783

  9. {9, 10, 6}

    {9, 6, 10}

    9

    Returns: 6.199327552481009

  10. {4, 5, 6}

    {3, 10, 4}

    6

    Returns: 0.0

  11. {10, 9, 0}

    {8, 7, 1}

    8

    Returns: 1.446784734832363

  12. {1, 10, 6}

    {3, 4, 2}

    5

    Returns: 21.59971975494591

  13. {7, 0}

    {6, 6}

    13

    Returns: 0.0

  14. {8, 8}

    {10, 5}

    16

    Returns: 0.0

  15. {5, 8}

    {1, 0}

    6

    Returns: 36.950808218494785

  16. {10, 0}

    {4, 3}

    12

    Returns: 0.0

  17. {2, 1}

    {0, 8}

    20

    Returns: 0.0

  18. {8}

    {5}

    20

    Returns: 0.0

  19. {9}

    {7}

    13

    Returns: 0.0

  20. {9}

    {5}

    3

    Returns: 79.9758737602333

  21. {8}

    {1}

    9

    Returns: 11.312822756583046

  22. {6}

    {0}

    3

    Returns: 85.86283306769292

  23. {0, 1, 5 }

    {0, 0, 3 }

    6

    Returns: 17.95288785134835

  24. {1, 2, 1 }

    {1, 2, 7 }

    5

    Returns: 37.387073599154974

  25. {3, 4, 5 }

    {3, 4, 5 }

    3

    Returns: 54.91357439296189

  26. {4, 8, 7 }

    {4, 1, 9 }

    4

    Returns: 14.492041513272852

  27. {2, 8 }

    {2, 8 }

    2

    Returns: 74.86725878970901

  28. {2, 3 }

    {2, 3 }

    3

    Returns: 69.48568580609845

  29. {0 }

    {0 }

    14

    Returns: 0.020271432863410155

  30. {2, 3, 4 }

    {2, 3, 4 }

    2

    Returns: 76.36025278755915

  31. {5 }

    {5 }

    5

    Returns: 21.460183689207042

  32. {2, 3 }

    {2, 3 }

    4

    Returns: 56.92738220209412

  33. {2, 3, 4 }

    {2, 3, 2 }

    4

    Returns: 51.900362185963786


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: