luogu#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 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 dollar and pay out dollars. Now suppose is . If you make bets in total before quitting and only of them pay out, your total loss is dollars. If of them pay out, you have gained dollars.
Given and the percentage probability 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 followed by the winning probability percentage . Both and have at most two digits after the decimal point.
输出格式
Display the maximum expected profit with an absolute error of at most .
题目大意
【题目描述】
“在赌场里,首要规则是让他们继续玩,让他们不断回来。他们玩得越久,输得越多,最终,我们会赢得一切。”
(摘自 1995 年电影《赌场》)
最近的经济衰退对包括赌博业在内的娱乐场所并不友好。赌场之间竞争激烈,以吸引有钱的玩家,一些赌场开始提供特别优厚的优惠。其中一个赌场提供以下优惠:你可以在赌场里随意赌博。当你结束时,如果你比开始时输了任何金额,赌场将退还你损失的 。显然,如果你赢钱了,你可以保留所有的奖金。此优惠没有时间限制或金额限制,但你只能兑现一次。
为了简化,假设所有赌注的成本为 美元,并支付 美元。现在假设 是 。如果你在退出前总共下注 次,只有 次获胜,你的总损失是 美元。如果 次获胜,你就赚了 美元。
给定 和赢得任何单个赌注的概率百分比 ,编写一个程序来确定你在这个赌场下注所能获得的最大期望利润,使用任何赌博策略。
输入由一个单一的测试用例组成。测试用例包含退款百分比 ,随后是赢得概率百分比 。 和 的小数点后最多有两位数字。
显示最大期望利润,绝对误差不超过 。
【输入格式】
输入由一个单一的测试用例组成。测试用例包含退款百分比 ,随后是赢得概率百分比 。 和 的小数点后最多有两位数字。
【输出格式】
输出最大期望利润,绝对误差不超过 。
翻译来自于:ChatGPT。
0 49.9
0.0
50 49.85
7.10178453