#P10616. [ICPC2013 WF] Hey, Better Bettor

[ICPC2013 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}.

题目大意

【题目描述】

“在赌场里,首要规则是让他们继续玩,让他们不断回来。他们玩得越久,输得越多,最终,我们会赢得一切。”
(摘自 1995 年电影《赌场》)

最近的经济衰退对包括赌博业在内的娱乐场所并不友好。赌场之间竞争激烈,以吸引有钱的玩家,一些赌场开始提供特别优厚的优惠。其中一个赌场提供以下优惠:你可以在赌场里随意赌博。当你结束时,如果你比开始时输了任何金额,赌场将退还你损失的 x%x\%。显然,如果你赢钱了,你可以保留所有的奖金。此优惠没有时间限制或金额限制,但你只能兑现一次。

为了简化,假设所有赌注的成本为 11 美元,并支付 22 美元。现在假设 xx2020。如果你在退出前总共下注 1010 次,只有 33 次获胜,你的总损失是 3.23.2 美元。如果 66 次获胜,你就赚了 22 美元。

给定 xx 和赢得任何单个赌注的概率百分比 pp,编写一个程序来确定你在这个赌场下注所能获得的最大期望利润,使用任何赌博策略。

输入由一个单一的测试用例组成。测试用例包含退款百分比 x(0x<100)x (0 \leq x < 100),随后是赢得概率百分比 p(0p<50)p (0 \leq p < 50)xxpp 的小数点后最多有两位数字。

显示最大期望利润,绝对误差不超过 10310^{-3}

【输入格式】

输入由一个单一的测试用例组成。测试用例包含退款百分比 x(0x<100)x (0 \leq x < 100),随后是赢得概率百分比 p(0p<50)p (0 \leq p < 50)xxpp 的小数点后最多有两位数字。

【输出格式】

输出最大期望利润,绝对误差不超过 10310^{-3}

翻译来自于:ChatGPT

0 49.9
0.0
50 49.85
7.10178453