Statistics

Problem Statement for "TieForMax"

Problem Statement

I have t tokens and p initially empty piles. One after another, I place each token onto a pile chosen uniformly at random. (All choices are mutually independent.)

What is the probability that once I'm done, multiple piles will be tied for being the largest?

Definition

Class:
TieForMax
Method:
getProbability
Parameters:
int, int
Returns:
double
Method signature:
double getProbability(int t, int p)
(be sure your method is public)

Notes

  • Your return value must have an absolute error at most 1e-9.

Constraints

  • t will be between 1 and 50, inclusive.
  • p will be between 1 and 50, inclusive.

Examples

  1. 7

    1

    Returns: 0.0

    I will make a single pile with seven tokens. With just one pile there can be no ties.

  2. 2

    2

    Returns: 0.5

    With probability 50% I will get a unique largest pile with two tokens, and with probability 50% I will get a tie: two piles with one token each.

  3. 3

    3

    Returns: 0.2222222222222222

    The tie can only happen if I get three piles with one token on each of them. The probability of that event is 6/27 = 2/9.

  4. 6

    4

    Returns: 0.380859375

    Now there are multiple configurations in which the maximum isn't unique. For example, the pile sizes can be {1,2,1,2}, {0,3,3,0}, or even {0,2,2,2}.

  5. 50

    50

    Returns: 0.49549217175140714

  6. 50

    1

    Returns: 0.0

  7. 50

    2

    Returns: 0.11227517265921705

  8. 44

    15

    Returns: 0.33001699751934377

  9. 5

    31

    Returns: 0.7263180804767839

  10. 50

    3

    Returns: 0.10878542928411916

  11. 9

    1

    Returns: 0.0

  12. 24

    17

    Returns: 0.42495356805756523

  13. 25

    5

    Returns: 0.21471557428462928

  14. 1

    17

    Returns: 0.0

  15. 2

    1

    Returns: 0.0

  16. 3

    21

    Returns: 0.8616780045351474

  17. 15

    16

    Returns: 0.43585062590862367

  18. 19

    23

    Returns: 0.4571632236266011

  19. 22

    37

    Returns: 0.5345127875026959

  20. 3

    11

    Returns: 0.743801652892562

  21. 32

    37

    Returns: 0.49279229282606474

  22. 41

    36

    Returns: 0.46905235614025453

  23. 2

    5

    Returns: 0.8

  24. 17

    16

    Returns: 0.41542972092942454

  25. 1

    2

    Returns: 0.0

  26. 35

    25

    Returns: 0.42317426811953307

  27. 29

    39

    Returns: 0.4820714816238115

  28. 50

    15

    Returns: 0.31422235926273756

  29. 19

    7

    Returns: 0.2990551413809619

  30. 21

    50

    Returns: 0.6358596072706825

  31. 50

    4

    Returns: 0.13308211101723455

  32. 11

    22

    Returns: 0.5449108970976813

  33. 25

    39

    Returns: 0.5012031087298271

  34. 49

    3

    Returns: 0.09306300267073653

  35. 38

    24

    Returns: 0.4072885789245172

  36. 2

    2

    Returns: 0.5

  37. 39

    49

    Returns: 0.5159893885043945

  38. 16

    25

    Returns: 0.5485650062644534

  39. 9

    24

    Returns: 0.47910243985929457

  40. 48

    45

    Returns: 0.48046472719616595

  41. 1

    1

    Returns: 0.0

  42. 25

    29

    Returns: 0.46365045529584514

  43. 10

    50

    Returns: 0.538429177796902

  44. 49

    35

    Returns: 0.43346326065860097

  45. 2

    47

    Returns: 0.9787234042553191

  46. 39

    28

    Returns: 0.4249141992532032

  47. 12

    29

    Returns: 0.55260438531691

  48. 2

    17

    Returns: 0.9411764705882353

  49. 10

    41

    Returns: 0.5122372788409225

  50. 40

    25

    Returns: 0.409842548427532

  51. 19

    31

    Returns: 0.5428608176924823

  52. 47

    22

    Returns: 0.37808489133629763

  53. 45

    2

    Returns: 0.0

  54. 18

    3

    Returns: 0.14122145718524426

  55. 35

    35

    Returns: 0.4949159314588264

  56. 2

    50

    Returns: 0.98

  57. 16

    31

    Returns: 0.5992335336918639

  58. 37

    37

    Returns: 0.4973596431344657

  59. 28

    17

    Returns: 0.3883386272497261

  60. 17

    39

    Returns: 0.6226721908569057

  61. 18

    36

    Returns: 0.6044374564780673

  62. 25

    44

    Returns: 0.5333603109590493

  63. 1

    47

    Returns: 0.0

  64. 28

    40

    Returns: 0.48449445645313927

  65. 50

    48

    Returns: 0.48501081581934014

  66. 24

    36

    Returns: 0.4946080805982409

  67. 49

    34

    Returns: 0.4314105039475389

  68. 5

    27

    Returns: 0.6934918457552203

  69. 30

    36

    Returns: 0.48433067198672786

  70. 36

    33

    Returns: 0.48139028784653637

  71. 34

    17

    Returns: 0.3785937650583756

  72. 33

    22

    Returns: 0.4090397618953522

  73. 50

    25

    Returns: 0.3920895759176388

  74. 15

    50

    Returns: 0.5779582335024485


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: