Statistics

Problem Statement for "HockeyPlayoff"

Problem Statement

An ice hockey playoff final is played as a sequence of matches. The winner is the first team that wins winsNeeded of those matches.

Teams A and B are facing off in such a final. The home ice alternates every two matches. That is, A plays the first two matches on their home ice, B plays matches 3 and 4 on their home ice, A plays matches 5 and 6 at home, and so on.

It is known that home and away games are completely different. In this matchup, we know the following about a single independent game between A and B:

  • If A plays at home ice, they win with probability AwinHome percent.
  • If B plays at home ice, they win with probability BwinHome percent.

There is a reason why we emphasized the words "single independent game" in the previous paragraph. In a playoff series there is one more factor that influences the win probability of each team: momentum. The team that keeps winning has a morale boost that makes it more likely that they will win the next match. In this problem, momentum works as follows: if a team has a streak of W won matches in a row, their win probability for the next match is increased by 5*W percent (up to a maximum of 100 percent, of course).

For example, if A won the first game of the series and B won the next three, in game five B has a 5*3 = 15 percent boost due to momentum.

You are given winsNeeded, AwinHome and BwinHome. Let P be the probability that team A will win the whole series. Let M = 2*winsNeeded-1 be the maximum number of matches in the series. It can be shown that X = P * 100^M is an integer. Compute and return the value (X modulo (10^9 + 7)).

Definition

Class:
HockeyPlayoff
Method:
winProbability
Parameters:
int, int, int
Returns:
int
Method signature:
int winProbability(int winsNeeded, int AwinHome, int BwinHome)
(be sure your method is public)

Constraints

  • winsNeeded will be between 1 and 600, inclusive.
  • AwinHome will be between 0 and 100, inclusive.
  • BwinHome will be between 0 and 100, inclusive.

Examples

  1. 3

    0

    100

    Returns: 0

    The first one to three wins will win the series. Team A is completely hopeless and always loses, so B will win this series 3:0.

  2. 4

    100

    0

    Returns: 999300007

    The diametrally opposite situation to Example 0. The answer is 100^7 modulo (10^9 + 7).

  3. 600

    50

    50

    Returns: 594375906

    A perfectly symmetric situation. The answer is (0.5 * 100^1199) modulo (10^9 + 7).

  4. 4

    53

    57

    Returns: 942200194

  5. 7

    93

    87

    Returns: 545426737

  6. 361

    55

    70

    Returns: 76373350

  7. 532

    65

    49

    Returns: 365848879

  8. 402

    53

    84

    Returns: 631219872

  9. 25

    0

    33

    Returns: 45144642

  10. 494

    40

    72

    Returns: 577479278

  11. 438

    30

    66

    Returns: 287922758

  12. 556

    30

    4

    Returns: 581365816

  13. 591

    88

    45

    Returns: 55868740

  14. 351

    30

    100

    Returns: 676383354

  15. 37

    42

    12

    Returns: 649356180

  16. 565

    69

    32

    Returns: 737804427

  17. 100

    89

    42

    Returns: 227120490

  18. 595

    14

    98

    Returns: 313374739

  19. 586

    36

    98

    Returns: 770769662

  20. 545

    68

    72

    Returns: 403504245

  21. 539

    72

    99

    Returns: 901322681

  22. 593

    66

    28

    Returns: 916982913

  23. 117

    48

    62

    Returns: 124617722

  24. 260

    56

    1

    Returns: 896131203

  25. 175

    9

    34

    Returns: 658005131

  26. 600

    55

    46

    Returns: 839481590

  27. 582

    77

    66

    Returns: 232581684

  28. 502

    73

    31

    Returns: 780940982

  29. 555

    88

    23

    Returns: 379891664

  30. 525

    16

    12

    Returns: 937829555

  31. 567

    50

    13

    Returns: 501642234

  32. 500

    83

    15

    Returns: 866496555

  33. 425

    47

    2

    Returns: 463711250

  34. 271

    17

    23

    Returns: 266544335

  35. 525

    100

    98

    Returns: 378732724

  36. 572

    72

    1

    Returns: 845774187

  37. 76

    19

    69

    Returns: 120205712

  38. 347

    79

    30

    Returns: 292097646

  39. 515

    2

    11

    Returns: 408153870

  40. 310

    70

    39

    Returns: 142195647

  41. 245

    70

    74

    Returns: 924638934

  42. 280

    72

    62

    Returns: 829014865

  43. 351

    14

    52

    Returns: 709892805

  44. 538

    72

    97

    Returns: 798233444

  45. 501

    8

    65

    Returns: 330976262

  46. 583

    100

    58

    Returns: 914965594

  47. 572

    66

    97

    Returns: 956312605

  48. 600

    90

    62

    Returns: 731785138

  49. 515

    96

    31

    Returns: 44657498

  50. 521

    59

    2

    Returns: 453814091

  51. 558

    35

    81

    Returns: 958104572

  52. 558

    71

    24

    Returns: 949502982

  53. 294

    98

    33

    Returns: 97961944

  54. 549

    8

    92

    Returns: 513193358

  55. 568

    95

    46

    Returns: 359259718

  56. 552

    98

    87

    Returns: 816552887

  57. 210

    13

    65

    Returns: 12078515

  58. 542

    68

    46

    Returns: 571280707

  59. 112

    79

    95

    Returns: 257480851

  60. 506

    44

    74

    Returns: 419288850

  61. 581

    34

    32

    Returns: 595404476

  62. 526

    59

    84

    Returns: 421312578

  63. 599

    56

    40

    Returns: 121251168

  64. 57

    74

    61

    Returns: 702019135

  65. 1

    54

    58

    Returns: 54

  66. 578

    32

    37

    Returns: 768472133

  67. 515

    21

    54

    Returns: 289600395

  68. 554

    30

    64

    Returns: 762529832

  69. 540

    71

    2

    Returns: 864242068

  70. 578

    71

    22

    Returns: 263258698

  71. 387

    23

    78

    Returns: 615827077

  72. 186

    62

    52

    Returns: 905299674

  73. 62

    59

    22

    Returns: 87757879

  74. 408

    79

    17

    Returns: 591153598

  75. 500

    49

    63

    Returns: 88540998

  76. 593

    15

    65

    Returns: 860108875

  77. 411

    11

    53

    Returns: 876206046

  78. 422

    79

    22

    Returns: 843390828

  79. 556

    76

    11

    Returns: 403396682

  80. 555

    95

    25

    Returns: 546442807

  81. 509

    16

    91

    Returns: 894113574

  82. 583

    83

    13

    Returns: 451646251

  83. 511

    45

    3

    Returns: 165797256

  84. 405

    76

    28

    Returns: 103510179

  85. 529

    64

    32

    Returns: 938518098

  86. 314

    71

    7

    Returns: 974807709

  87. 294

    62

    89

    Returns: 90870138

  88. 578

    60

    0

    Returns: 647315212

  89. 410

    80

    70

    Returns: 762532062

  90. 384

    43

    8

    Returns: 418077371

  91. 161

    30

    23

    Returns: 761558015

  92. 82

    65

    21

    Returns: 331856605

  93. 170

    11

    16

    Returns: 699981881

  94. 515

    53

    37

    Returns: 719155837

  95. 563

    86

    44

    Returns: 476782507

  96. 513

    4

    25

    Returns: 603978052

  97. 573

    42

    11

    Returns: 9900420

  98. 564

    69

    73

    Returns: 739982769

  99. 581

    56

    55

    Returns: 892784994

  100. 502

    24

    41

    Returns: 549688626

  101. 512

    56

    98

    Returns: 122355611

  102. 597

    12

    42

    Returns: 651402321

  103. 448

    42

    100

    Returns: 902576102

  104. 560

    94

    66

    Returns: 250169245

  105. 487

    29

    25

    Returns: 467069104

  106. 600

    51

    52

    Returns: 355333564


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: