Statistics

Problem Statement for "Archery"

Problem Statement

In archery, you shoot an arrow at a target and you get some number of points depending on where the arrow hits the target. In this problem, the target is a circle divided into N concentric rings and a central circle. The width of each ring and the radius of the central circle are equal. The point values assigned to each section of the target are given in the int[] ringPoints. The values are given in order, from innermost to outermost section, so ringPoints[0] is the number of points you get for hitting the central circle, and ringPoints[N] is the number of points you get for hitting the outermost ring.
You are a beginning archer. Whenever you take a shot, the arrow always lands somewhere on the target, but it hits a random point, and all points on the target have an equal probability of being hit. Return the expected point value of your shot.

Definition

Class:
Archery
Method:
expectedPoints
Parameters:
int, int[]
Returns:
double
Method signature:
double expectedPoints(int N, int[] ringPoints)
(be sure your method is public)

Notes

  • The probability of hitting a specific section of the target is defined as the area of the section divided by the total area of the target.
  • The expected point value of a shot is calculated as follows. For each section of the target, multiply its point value by the probability of hitting that section. The expected point value is the sum of all these values.
  • The returned value must have an absolute or relative error less than 1e-9.

Constraints

  • N will be between 1 and 49, inclusive.
  • ringPoints will contain exactly N+1 elements.
  • Each element of ringPoints will be between 0 and 100, inclusive.

Examples

  1. 1

    {10, 0}

    Returns: 2.5

    You score 10 if you hit the central circle, and 0 otherwise. The area of the central circle is 0.25 of the total target area.

  2. 3

    {1, 1, 1, 1}

    Returns: 1.0

    Regardless of what part of the target you hit, you get 1 point.

  3. 4

    {100, 0, 100, 0, 100}

    Returns: 60.0

    Only even rings of the target give you points.

  4. 9

    {69, 50, 79, 16, 52, 71, 17, 96, 56, 32}

    Returns: 51.96

  5. 40

    {39, 82, 20, 86, 26, 54, 96, 27, 45, 96, 32, 85, 37, 51, 60, 22, 38, 80, 89, 27, 43, 59, 39, 83, 23, 30, 79, 33, 55, 80, 70, 27, 6, 35, 18, 48, 32, 72, 52, 90, 5}

    Returns: 48.11957168352171

  6. 43

    {85, 16, 15, 53, 63, 28, 33, 21, 68, 49, 58, 15, 27, 27, 76, 29, 95, 3, 15, 98, 47, 97, 29, 21, 6, 97, 52, 36, 49, 69, 92, 5, 88, 6, 89, 21, 94, 8, 20, 62, 19, 11, 63, 18}

    Returns: 44.5025826446281

  7. 47

    {46, 79, 29, 0, 46, 54, 57, 42, 59, 83, 65, 3, 89, 33, 12, 32, 2, 59, 2, 7, 5, 38, 4, 41, 38, 70, 47, 62, 77, 1, 13, 35, 69, 95, 6, 70, 79, 73, 8, 39, 16, 77, 6, 26, 32, 36, 44, 41}

    Returns: 40.02734375

  8. 12

    {75, 20, 23, 99, 74, 42, 29, 17, 78, 10, 39, 98, 98}

    Returns: 57.64497041420118

  9. 13

    {19, 64, 37, 9, 32, 53, 20, 40, 3, 23, 49, 43, 48, 81}

    Returns: 41.23979591836735

  10. 41

    {64, 15, 98, 86, 31, 13, 76, 11, 73, 33, 43, 83, 92, 62, 61, 50, 17, 31, 42, 82, 16, 5, 68, 28, 70, 94, 13, 87, 50, 58, 1, 0, 76, 55, 8, 21, 87, 97, 90, 50, 96, 29}

    Returns: 52.03061224489796

  11. 19

    {16, 42, 65, 46, 3, 56, 30, 9, 26, 62, 50, 54, 57, 91, 10, 73, 34, 88, 31, 26}

    Returns: 46.667500000000004

  12. 17

    {52, 9, 46, 10, 51, 87, 80, 13, 37, 8, 100, 2, 27, 91, 56, 6, 43, 12}

    Returns: 39.31481481481481

  13. 42

    {56, 9, 84, 1, 75, 72, 58, 71, 79, 72, 50, 55, 13, 88, 88, 54, 27, 58, 75, 59, 31, 7, 40, 71, 30, 52, 46, 68, 34, 60, 53, 84, 2, 66, 75, 41, 51, 88, 20, 11, 87, 2, 67}

    Returns: 50.31692806922661

  14. 21

    {7, 59, 44, 89, 62, 0, 43, 75, 21, 76, 53, 17, 32, 68, 76, 50, 61, 35, 43, 49, 45, 98}

    Returns: 53.2293388429752

  15. 48

    {94, 33, 68, 25, 14, 14, 39, 18, 26, 7, 80, 36, 78, 38, 5, 56, 79, 10, 59, 32, 64, 45, 96, 5, 5, 13, 53, 17, 74, 10, 74, 95, 17, 98, 93, 60, 42, 11, 41, 75, 32, 67, 33, 47, 52, 30, 29, 12, 91}

    Returns: 46.46230737192836

  16. 22

    {29, 22, 37, 99, 81, 8, 88, 34, 38, 83, 15, 72, 55, 67, 62, 18, 11, 14, 42, 88, 18, 45, 58}

    Returns: 45.93572778827977

  17. 12

    {24, 51, 64, 56, 2, 93, 33, 67, 56, 71, 92, 12, 94}

    Returns: 60.49112426035503

  18. 15

    {28, 46, 94, 93, 15, 39, 58, 28, 24, 55, 39, 61, 17, 84, 37, 3}

    Returns: 41.24609375

  19. 44

    {49, 86, 78, 73, 71, 75, 0, 67, 50, 74, 38, 38, 54, 42, 55, 93, 44, 35, 26, 59, 25, 62, 64, 69, 89, 75, 93, 87, 37, 54, 18, 88, 2, 88, 89, 60, 90, 86, 91, 86, 62, 43, 89, 88, 38}

    Returns: 64.49382716049382

  20. 27

    {36, 56, 89, 72, 40, 13, 34, 80, 83, 66, 61, 99, 43, 82, 42, 88, 51, 67, 74, 66, 76, 22, 18, 44, 39, 21, 33, 5}

    Returns: 48.52295918367347

  21. 33

    {49, 70, 19, 64, 11, 12, 71, 31, 5, 17, 37, 75, 77, 48, 12, 36, 47, 71, 57, 75, 15, 53, 85, 57, 2, 53, 84, 4, 53, 19, 71, 50, 62, 3}

    Returns: 44.819204152249135

  22. 23

    {1, 3, 16, 48, 87, 17, 73, 54, 21, 41, 86, 47, 8, 43, 58, 85, 10, 76, 96, 86, 100, 38, 84, 20}

    Returns: 57.64930555555555

  23. 36

    {51, 48, 87, 82, 4, 97, 46, 3, 67, 71, 73, 50, 3, 48, 19, 85, 93, 77, 10, 0, 42, 72, 27, 61, 65, 99, 96, 27, 98, 57, 91, 38, 53, 100, 25, 89, 44}

    Returns: 59.03140978816654

  24. 11

    {95, 75, 61, 14, 11, 82, 30, 68, 44, 96, 56, 53}

    Returns: 56.25694444444445

  25. 7

    {22, 89, 28, 70, 6, 6, 1, 50}

    Returns: 28.15625

  26. 21

    {33, 0, 63, 94, 15, 52, 84, 85, 89, 20, 89, 75, 48, 71, 41, 41, 23, 74, 23, 45, 34, 68}

    Returns: 52.514462809917354

  27. 36

    {74, 83, 90, 75, 12, 93, 26, 22, 47, 13, 1, 80, 34, 60, 82, 72, 70, 90, 20, 55, 70, 72, 60, 77, 6, 34, 42, 76, 36, 93, 34, 0, 70, 40, 69, 77, 18}

    Returns: 51.52154857560263

  28. 4

    {77, 13, 80, 59, 37}

    Returns: 50.480000000000004

  29. 20

    {46, 13, 50, 47, 30, 24, 78, 24, 92, 79, 100, 2, 100, 14, 96, 33, 53, 64, 90, 52, 98}

    Returns: 63.11337868480725

  30. 45

    {66, 0, 18, 78, 12, 2, 33, 10, 66, 88, 23, 36, 71, 38, 39, 86, 16, 71, 22, 84, 49, 81, 11, 44, 51, 44, 27, 72, 10, 10, 31, 85, 31, 17, 14, 74, 64, 38, 79, 74, 15, 50, 11, 16, 100, 42}

    Returns: 44.92013232514177

  31. 22

    {66, 54, 75, 56, 62, 66, 2, 83, 2, 25, 78, 15, 88, 59, 34, 17, 72, 5, 15, 15, 65, 87, 94}

    Returns: 48.534971644612476

  32. 34

    {71, 95, 43, 34, 99, 47, 91, 48, 29, 10, 62, 34, 54, 3, 80, 23, 41, 73, 76, 54, 77, 39, 19, 49, 32, 77, 70, 86, 12, 5, 23, 89, 25, 2, 38}

    Returns: 44.46857142857143

  33. 28

    {66, 6, 31, 46, 65, 100, 18, 80, 64, 58, 66, 87, 80, 51, 26, 17, 69, 33, 30, 32, 95, 80, 63, 93, 90, 14, 19, 78, 43}

    Returns: 56.026159334126035

  34. 21

    {40, 41, 22, 71, 59, 30, 66, 22, 74, 97, 60, 21, 22, 1, 41, 7, 78, 14, 13, 70, 69, 32}

    Returns: 41.582644628099175

  35. 16

    {99, 32, 89, 32, 76, 29, 94, 30, 32, 71, 88, 21, 71, 68, 81, 34, 88}

    Returns: 61.179930795847746

  36. 40

    {67, 30, 26, 52, 84, 73, 39, 9, 23, 82, 15, 49, 74, 68, 7, 9, 88, 54, 36, 96, 1, 8, 46, 52, 85, 23, 8, 49, 64, 47, 35, 84, 10, 71, 64, 67, 18, 82, 91, 76, 26}

    Returns: 50.354550862581796

  37. 21

    {4, 79, 37, 17, 72, 38, 14, 3, 41, 70, 9, 24, 16, 42, 81, 37, 54, 15, 66, 81, 67, 60}

    Returns: 47.25413223140495

  38. 10

    {85, 4, 30, 53, 31, 38, 65, 17, 19, 31, 22}

    Returns: 31.314049586776857

  39. 41

    {12, 17, 56, 1, 80, 18, 44, 31, 71, 93, 15, 84, 8, 34, 5, 25, 50, 65, 93, 55, 9, 88, 4, 78, 10, 20, 21, 84, 37, 81, 35, 74, 6, 91, 44, 33, 15, 65, 35, 6, 80, 90}

    Returns: 47.02777777777778

  40. 11

    {4, 31, 58, 26, 44, 60, 11, 59, 9, 17, 11, 46}

    Returns: 30.680555555555557

  41. 4

    {24, 12, 97, 6, 57}

    Returns: 44.0

  42. 12

    {45, 46, 81, 14, 57, 59, 24, 2, 82, 62, 13, 95, 59}

    Returns: 51.44970414201183

  43. 48

    {63, 59, 79, 80, 40, 40, 64, 45, 88, 55, 36, 64, 77, 34, 42, 76, 13, 12, 57, 85, 60, 29, 82, 22, 80, 12, 51, 56, 31, 63, 22, 67, 41, 86, 76, 93, 36, 28, 49, 94, 64, 67, 37, 55, 0, 97, 100, 76, 1}

    Returns: 54.59142024156601

  44. 3

    {4, 8, 95, 83}

    Returns: 67.75

  45. 39

    {3, 67, 98, 32, 21, 38, 19, 20, 77, 95, 55, 11, 58, 94, 91, 56, 15, 40, 20, 67, 67, 84, 73, 86, 85, 71, 36, 87, 92, 51, 69, 52, 7, 31, 46, 52, 86, 52, 70, 30}

    Returns: 57.152499999999996

  46. 12

    {87, 53, 4, 10, 97, 88, 87, 14, 57, 91, 37, 97, 87}

    Returns: 67.44970414201183

  47. 27

    {92, 46, 14, 61, 97, 27, 7, 28, 44, 74, 53, 0, 8, 0, 16, 67, 29, 87, 31, 92, 56, 86, 76, 43, 91, 67, 80, 48}

    Returns: 55.285714285714285

  48. 36

    {28, 70, 72, 82, 41, 6, 10, 86, 96, 58, 39, 89, 23, 50, 32, 65, 55, 34, 66, 99, 49, 63, 51, 89, 76, 74, 99, 17, 96, 20, 60, 85, 75, 76, 52, 10, 45}

    Returns: 59.09130752373996

  49. 43

    {57, 53, 3, 53, 80, 87, 14, 17, 21, 36, 73, 64, 60, 79, 14, 23, 27, 53, 92, 62, 59, 66, 35, 85, 34, 8, 96, 94, 89, 35, 99, 27, 29, 54, 4, 12, 79, 89, 84, 13, 34, 36, 3, 93}

    Returns: 51.02014462809917

  50. 18

    {44, 50, 89, 95, 81, 87, 10, 76, 94, 27, 57, 37, 82, 6, 37, 80, 16, 80, 51}

    Returns: 53.73684210526316

  51. 29

    {25, 67, 27, 99, 3, 5, 61, 2, 73, 87, 7, 100, 85, 58, 13, 100, 12, 88, 62, 35, 5, 79, 69, 57, 82, 96, 93, 0, 17, 16}

    Returns: 51.93888888888889

  52. 43

    {94, 41, 62, 35, 61, 44, 79, 90, 16, 22, 33, 65, 9, 94, 8, 1, 88, 87, 20, 71, 26, 6, 91, 33, 55, 40, 85, 32, 30, 4, 48, 45, 59, 44, 73, 52, 69, 54, 94, 7, 50, 99, 13, 94}

    Returns: 51.22055785123967

  53. 36

    {98, 78, 94, 99, 64, 17, 51, 32, 7, 32, 9, 58, 98, 78, 70, 52, 34, 5, 94, 97, 1, 46, 0, 82, 97, 21, 70, 100, 84, 41, 78, 45, 53, 54, 21, 88, 16}

    Returns: 54.084733382030684

  54. 25

    {99, 80, 66, 19, 95, 64, 19, 25, 75, 83, 35, 1, 11, 95, 63, 11, 81, 40, 91, 58, 69, 21, 28, 47, 61, 19}

    Returns: 48.02071005917159

  55. 36

    {73, 7, 19, 70, 34, 53, 33, 97, 97, 76, 55, 11, 81, 19, 89, 14, 84, 85, 53, 100, 88, 87, 0, 36, 46, 20, 37, 21, 17, 11, 17, 60, 96, 100, 87, 46, 19}

    Returns: 51.55295836376917

  56. 1

    {0,0}

    Returns: 0.0

  57. 9

    {69, 50, 79, 16, 52, 71, 17, 96, 56, 32 }

    Returns: 51.96

  58. 4

    {100, 0, 100, 0, 100 }

    Returns: 60.0

  59. 1

    {10, 0 }

    Returns: 2.5

  60. 11

    {11, 70, 50, 0, 12, 3, 4, 5, 4, 23, 23, 0 }

    Returns: 11.993055555555555


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: