TopCoder problem "ShootingGallery" used in TCHS SRM 15 (Division I Level Two)



Problem Statement

    You and your friend are at a shooting gallery, and your friend wants to make a bet that he can hit the target within a certain number of shots. You know that each time he takes a shot, there is an accuracy percent probability that he will hit the target. Return the maximal number of shots at which it is advantageous for you to take the bet. A number n is considered advantageous if the probability that your friend will hit the target in n or less shots is less than 50%.
 

Definition

    
Class:ShootingGallery
Method:profitableBet
Parameters:int
Returns:int
Method signature:int profitableBet(int accuracy)
(be sure your method is public)
    
 

Notes

-All shots are independent.
-Hint: Try to calculate the probability that your friend will NOT hit the target in n or less shots.
 

Constraints

-accuracy will be between 1 and 100, inclusive.
 

Examples

0)
    
40
Returns: 1
In this case, he will hit the target in one shot with probability 0.4, and in two or less shots with probability 0.74.
1)
    
20
Returns: 3
In one shot - 0.2.

In two or less shots - 0.36.

In three or less shots - 0.488.

In four or less shots - 0.5904.
2)
    
50
Returns: 0
3)
    
1
Returns: 68

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10067&pm=6588

Writer:

Vedensky

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Brute Force