SQLServer Decimal数据类型怎么赋值
243
2022-08-27
HDU 5781 ATM Mechine (概率dp)(求最优策略期望)
ATM Mechine
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 559 Accepted Submission(s): 245
Problem Description
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 K RMB(that means Alice's deposit x is a random integer between 0 and K (inclusively)). Every time Alice can try to take some money y out of the ATM. if her deposit is not small than y, ATM will give Alice y RMB immediately. But if her deposit is small than y, Alice will receive a warning from the ATM. If Alice has been warning more then W 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.
Input
The input contains multiple test cases. Each test case contains two numbers K and W.1≤K,W≤2000
Output
For each test case output the answer, rounded to 6 decimal places.
Sample Input
1 1 4 2 20 3
Sample Output
1.000000 2.400000 4.523810
Author
ZSTU
Source
Recommend
wange2014 | We have carefully selected several similar problems for you:
题意:有个人去ATM机里取钱,但是他不知道卡里有多少钱,而且这台ATM机不提供查询余额的功能,他只知道钱的上限 K, 每次他都要取一定的钱 y , 如果他的存款大于等于y, 他就得到 y钱 , 如果取的钱超过了余额,他就会被警告 1 次,求在最优策略下,取的钱上限是 K,警告次数不超过 W 。问你取钱次数期望最小是多少。
题解:E(i,j):存款的范围是 [0,i] , 还可以被警告 j次的期望值。假如Alice使用的是二分策略,那么在最坏情况下至多被警告⌈log2K⌉ 次。于是W=min(W,15) 就可以了。
E(i,j) = Minik=1i−k+1i+1∗E(i−k,j)+ki+1∗E(k−1,j−1)+1 这样时间复杂度是O(K2∗W)的。 然后有人问 y是不是要整数。由于存款是整数,你取小数的钱没有任何意义啊。
AC代码:
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~