TopCoder problem "PrimeSoccer" used in SRM 422 (Division I Level One , Division II Level Two)



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

0)
    
50
50
Returns: 0.5265618908306351
1)
    
100
100
Returns: 0.0
Both teams will score a goal in each interval, so the final result will be 18 to 18.
2)
    
12
89
Returns: 0.6772047168840167

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=10033

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13513&pm=10033

Writer:

mateuszek

Testers:

PabloGilberto , Olexiy , ivan_metelsky , ged

Problem categories:

Dynamic Programming, Math