概率DP HDU 4586 play the dice
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=4586
解题思路:
只考虑第一次,获得的金币的平均值为sum/n.sum为所有色子的面的金币值相加。
对于运气好,摇中了可以再来一次,该轮就能获得m/n*(sum/n)
运气好,又再来一次,该轮能获得(m/n)^2*(sum/n)
无穷无尽的摇下去,一共能获得sum/n*(1+p + p^2+`````+p^k + ````),其中p = m/n
将式子化简,就能得到E = sum/(n-m)。所以当sum = 0时为0,n=m时为inf。其余就为sum/(n-m)。
贴代码:
#include<cstdio>
int main()
{
// freopen("in.c","r",stdin);
int n,m,a;
while(~scanf("%d",&n))
{
int sum =;
for(int i=; i<n; ++i)
{
scanf("%d",&a);
sum += a;
}
scanf("%d",&m);
for(int i=; i<m; ++i)
scanf("%d",&a);
if(sum == ) printf("0.00\n");
else if(n == m )printf("inf\n");
else printf("%.2f\n",(double)sum/(n-m));
}
return ;
}
概率DP HDU 4586 play the dice的更多相关文章
- 概率DP hdu 3366 .
题意:一个人被困在一个城堡里,面前有n条路,他自己有m百万元,选择每一条路都有p概率通过,q概率遇到士兵,1-p-q概率道路不通:遇到士兵的话需要上交1百万,如果不够钱,则被杀死,问的是最优情况下多少 ...
- hdu 4586 Play the Dice(概率dp)
Problem Description There is a dice with n sides, which are numbered from 1,2,...,n and have the equ ...
- hdu 4586 Play the Dice 概率推导题
A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- hdu 4586 Play the Dice (概率+等比数列)
Play the Dice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) To ...
- HDU 4586 Play the Dice (数学,概率,等比公式,极限)
题意:给你一个n面的骰子每个面有一个值,然后其中有不同值代表你能获得的钱,然后有m个特殊的面,当你骰到这一面的时候可以获得一个新的机会 问你能得到钱的期望. 析: 骰第一次 sum/n 骰第二 ...
- 概率dp HDU 4405
Aeroplane chess Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Sub ...
- 概率dp HDU 3853
H - LOOPS Time Limit:5000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ci ...
- [概率dp] hdu 5378 Leader in Tree Land
题意: 给你一颗以1位根节点的树.我们定义对于每一个子树,节点权值最大的权值记为这个子树的权值,为你将1~n放到这个树里 满足最大权值仅仅有k个的组合数是多少. 思路: 我们能够知道以每一个节点为子树 ...
- HDU 4586 Play the Dice(数学期望)
Play the Dice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tot ...
随机推荐
- Codeforces 545D - Queue
545D - Queue 思路:忍耐时间短的排在前面,从小到大排序,贪心模拟,记录当前等待时间,如过等待时间大于当前的这个人得忍耐时间,那么就把这个人扔到最后面,不要管他了(哼╭(╯^╰)╮,谁叫你那 ...
- NotifyIcon实现托盘程序
NotifyIcon 控件的常用属性属性:Icon类型:System.Drawing.Icon说明:将在系统任务栏中显示的图标.可以在设计时指定,也可在运行时动态指定.属性:Text类型:String ...
- 同步代码时忽略maven项目 target目录
方式一: 在项目代码路径,如: F:\xyx\sl 鼠标右键,“TortoiseSVN”-- >“Settings” -->"Subversion"-->&qu ...
- EBS管理员为供应商创建新联系人流程
管理员为供应商创建新联系人流程 /oracle/apps/pos/supplier/webui/ByrAddCntctPG oracle.apps.pos.supplier.webui.ByrAddC ...
- Java容器涉及的类(代码)
Customer: public class Customer implements Comparable{ private Integer customerId; private String cu ...
- Oracle 12cR1中性能优化新特性之全数据库缓冲模式
通常情况下,Oracle会决定哪些数据会留在缓冲区中.当没足够的空间时,数据会被写出内存.此外,为了避免大量读取将有用的信息挤出缓冲区,Oracle对有些操作也许会才去绕过缓冲区的措施.Oracle1 ...
- spring boot 学习(三)API注解记录及测试
spring boot API注解记录及测试 部分注解解析 @Controller : 修饰创建处理 http 处理对象,一般用于页面渲染时使用. @RestController : Json数据交互 ...
- 遍历HashMap的方法(四)
Map map = new HashMap(); for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) { Map.Entr ...
- Openwrt WiFi Configure(1)
1 Scope of Document This document describes how to custom wifi option 2 Requiremen 2.1 ...
- bzoj2463
题解: 当n为奇数,输出Bob 否则输出Alice 代码: #include<bits/stdc++.h> using namespace std; int n; int main() { ...