#P10616. [ICPC 2013 WF] Hey, Better Bettor

    ID: 10054 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>2013Special JudgeO2优化ICPC

[ICPC 2013 WF] Hey, Better Bettor

题目背景

“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 x%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 11 dollar and pay out 22 dollars. Now suppose xx is 2020. If you make 1010 bets in total before quitting and only 33 of them pay out, your total loss is 3.23.2 dollars. If 66 of them pay out, you have gained 22 dollars.

Given xx and the percentage probability pp 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.

输入格式

The input consists of a single test case. A test case consists of the refund percentage x(0x<100)x (0 \leq x < 100) followed by the winning probability percentage p(0p<50)p (0 \leq p < 50). Both xx and pp have at most two digits after the decimal point.

输出格式

Display the maximum expected profit with an absolute error of at most 10310^{-3}.

0 49.9
0.0
50 49.85
7.10178453