eolymp
bolt
Try our new interface for solving problems
Problems

Hey, Better Bettor

Hey, Better Bettor

"\textit{In the casino, the cardinal rule is to keep them playing and to keep them coming back. The longer they play, the more they lose, and in the end, we get it all.}" (from the 1995 film Casino) Recent recessions have not been kind to entertainment venues, including the gambling industry. Competition is fierce among casinos to attract players with lots of money, and some have begun to offer especially sweet deals. One casino is offering the following: you can gamble as much as you want at the casino. After you are finished, if you are down by any amount from when you started, the casino will refund \textbf{x}\% of your losses to you. Obviously, if you are ahead, you can keep all of your winnings. There is no time limit or money limit on this offer, but you can redeem it only once. For simplicity, assume all bets cost \textbf{1} dollar and pay out \textbf{2} dollars. Now suppose \textbf{x} is \textbf{20}. If you make 10 bets in total before quitting and only \textbf{3} of them pay out, your total loss is \textbf{3.2} dollars. If \textbf{6} of them pay out, you have gained \textbf{2} dollars. Given \textbf{x} and the percentage probability \textbf{p} of winning any individual bet, write a program to determine the maximum expected profit you can make from betting at this casino, using any gambling strategy. \InputFile The input consists of a single test case. A test case consists of the refund percentage \textbf{x} (\textbf{0} ≤ \textbf{x} < \textbf{100}) followed by the winning probability percentage \textbf{p} (\textbf{0} ≤ \textbf{p} < \textbf{50}). Both \textbf{x} and \textbf{p} have at most two digits after the decimal point. \OutputFile Display the maximum expected profit with an absolute error of at most \textbf{10^\{-3\}}.
Time limit 4 seconds
Memory limit 256 MiB
Input example #1
0 49.9
Output example #1
0.0
Source ACM-ICPC World Finals 2013