Statistics

Problem Statement for "PrimeSoccer"

Problem Statement

You are watching a soccer match, and you wonder what the probability is that at least one of the two teams will score a prime number of goals. The game lasts 90 minutes, and to simplify the analysis, we will split the match into five-minute intervals. The first interval is the first five minutes, the second interval is the next five minutes, and so on. During each interval, there is a skillOfTeamA percent probability that team A will score a goal, and a skillOfTeamB percent probability that teamB will score a goal. Assume that each team will score at most one goal within each interval. Return the probability that at least one team will have a prime number as its final score.

Definition

Class:
PrimeSoccer
Method:
getProbability
Parameters:
int, int
Returns:
double
Method signature:
double getProbability(int skillOfTeamA, int skillOfTeamB)
(be sure your method is public)

Notes

  • The returned value must be accurate to within a relative or absolute value of 1E-9.
  • A prime number is a number that has exactly two divisors, 1 and itself. Note that 0 and 1 are not prime.

Constraints

  • skillOfTeamA will be between 0 and 100, inclusive.
  • skillOfTeamB will be between 0 and 100, inclusive.

Examples

  1. 50

    50

    Returns: 0.5265618908306351

  2. 100

    100

    Returns: 0.0

    Both teams will score a goal in each interval, so the final result will be 18 to 18.

  3. 12

    89

    Returns: 0.6772047168840167

  4. 43

    12

    Returns: 0.6967817545210753

  5. 55

    100

    Returns: 0.32120857144574655

  6. 0

    50

    Returns: 0.3119316101074219

  7. 0

    0

    Returns: 0.0

  8. 1

    1

    Returns: 0.02727121816404319

  9. 1

    100

    Returns: 0.01372986366008384

  10. 99

    1

    Returns: 0.1633771511659839

  11. 78

    11

    Returns: 0.6480645387523168

  12. 17

    17

    Returns: 0.8352494291961116

  13. 18

    19

    Returns: 0.8345272105589906

  14. 17

    23

    Returns: 0.8240750197973934

  15. 17

    83

    Returns: 0.6970466307894632

  16. 78

    12

    Returns: 0.6676645940835624

  17. 19

    19

    Returns: 0.8336063890380028

  18. 20

    20

    Returns: 0.8300960715969234

  19. 83

    83

    Returns: 0.44291092001576443

  20. 76

    89

    Returns: 0.5172470324584015

  21. 42

    94

    Returns: 0.6011829426223376

  22. 1

    9

    Returns: 0.4417697199997768

  23. 8

    7

    Returns: 0.5923754549464548

  24. 3

    5

    Returns: 0.2942561210017241

  25. 19

    21

    Returns: 0.8294554174803039

  26. 99

    99

    Returns: 0.28043890109834946

  27. 33

    44

    Returns: 0.6427002434550181

  28. 78

    43

    Returns: 0.5330449279924205

  29. 43

    76

    Returns: 0.546525257727783

  30. 38

    72

    Returns: 0.6058808825290922

  31. 42

    44

    Returns: 0.5746012495371897

  32. 12

    26

    Returns: 0.7854068947455727

  33. 19

    29

    Returns: 0.7984336328904318

  34. 74

    47

    Returns: 0.5415780571348757

  35. 24

    25

    Returns: 0.8000888645683668

  36. 1

    99

    Returns: 0.1633771511659839

  37. 18

    80

    Returns: 0.7026232773993955

  38. 34

    46

    Returns: 0.6272304912663792

  39. 53

    87

    Returns: 0.5034477777634486

  40. 28

    32

    Returns: 0.7446137516111067

  41. 23

    12

    Returns: 0.7986542487841684

  42. 20

    40

    Returns: 0.7432251317619454

  43. 13

    87

    Returns: 0.6790280442414693


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: