本题来源于:ATM Machine - 2016 Multi-University Training Contest 5
一个人去 ATM 机里取钱,但是他不记得卡里有多少钱了,而且这个 ATM 机不提供查询的功能,他知道钱的上限是 ,每次他都要取一定的钱 ,如果他的存款余额大于等于 ,他马上就得到 元钱,如果 超过了余额,他就会被警告 次,如果超过 次警告,警察就会过来抓他。求在最优策略下,取钱的期望次数。
有多组测试数据,EOF 结束,每组数据一行两个整数 。
输出答案,保留 位小数。
1 1
1.000000
4 2
2.400000
20 3
4.523810
题意补充:取的钱数必须是正整数,要求在保证取完钱和警告次数不超的情况下最小化期望次数。初始卡里的钱数在 等概率随机。
Alice is going to take all her savings out of the ATM (Automatic Teller Machine). Alice forget how many deposit she has, and this strange ATM doesn't support query deposit. The only information Alice knows about her deposit is the upper bound is RMB(that means Alice's deposit is a random integer between and $K4 (inclusively)).
Every time Alice can try to take some money out of the ATM. if her deposit is not small than , ATM will give Alice RMB immediately. But if her deposit is small than , Alice will receive a warning from the ATM.
If Alice has been warning more then times, she will be taken away by the police as a thief.
Alice hopes to operate as few times as possible.
As Alice is clever enough, she always take the best strategy.
Please calculate the expectation times that Alice takes all her savings out of the ATM and goes home, and not be taken away by the police.
The input contains multiple test cases. Each test case contains two numbers and .
For each test case output the answer, rounded to decimal places.
1 1
4 2
20 3
1.000000
2.400000
4.523810