题目链接:

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的更多相关文章

  1. 概率DP hdu 3366 .

    题意:一个人被困在一个城堡里,面前有n条路,他自己有m百万元,选择每一条路都有p概率通过,q概率遇到士兵,1-p-q概率道路不通:遇到士兵的话需要上交1百万,如果不够钱,则被杀死,问的是最优情况下多少 ...

  2. 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 ...

  3. hdu 4586 Play the Dice 概率推导题

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  4. hdu 4586 Play the Dice (概率+等比数列)

    Play the Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) To ...

  5. HDU 4586 Play the Dice (数学,概率,等比公式,极限)

    题意:给你一个n面的骰子每个面有一个值,然后其中有不同值代表你能获得的钱,然后有m个特殊的面,当你骰到这一面的时候可以获得一个新的机会 问你能得到钱的期望. 析: 骰第一次     sum/n 骰第二 ...

  6. 概率dp HDU 4405

    Aeroplane chess Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  7. 概率dp HDU 3853

    H - LOOPS Time Limit:5000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ci ...

  8. [概率dp] hdu 5378 Leader in Tree Land

    题意: 给你一颗以1位根节点的树.我们定义对于每一个子树,节点权值最大的权值记为这个子树的权值,为你将1~n放到这个树里 满足最大权值仅仅有k个的组合数是多少. 思路: 我们能够知道以每一个节点为子树 ...

  9. HDU 4586 Play the Dice(数学期望)

    Play the Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tot ...

随机推荐

  1. CentOS Gnome字体不清晰

    需要安装字体:dejavu-sans-mono-fonts The package you need to install is dejavu-sans-mono-fonts. This is the ...

  2. 总是有个yumBackend.py阻止我用yum进行更新

    [Another app is currently holding the yum lock; waiting for it to exit...] 上网查了,好像是说帮我安个桌面图标的进程. 估计是 ...

  3. centos系统lvm的安装

    今天安装redhat6.1在分区时提示”可引导分区不能位于逻辑卷上“,原来linux的引导区不能放在逻辑卷上. 解决方法: 1.先建立一个物理分区划给/boot分区 2.剩下的空间划给lvm. 然后开 ...

  4. 3.3 x86指令简介

    计算机组成 3 指令系统体系结构 3.3 x86指令简介 x86指令种类繁多,数量庞大.在这一节我们将会学习x86指令的分类,并分析其中最为基础的一部分指令. 通常一个指令系统主要包括这几类指令.运算 ...

  5. php--------ThinkPHP3.2验证码使用

    Thinkphp框架验证码的路径目录:ThinkPHP -> Library -> Think -> Verify.class.php ,只要在控制器中实例化这个类就能实现验证码的功 ...

  6. windows下线程间的通信方式

    1.事件: (在信息交换函数中将控件的值与控件id进行绑定,这样我们就可以更新或者获取控件的值) void CMy0722ThreadTalkingDlg::DoDataExchange(CDataE ...

  7. hdu-1850-nim

    Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32 ...

  8. Android 时钟(由秒转变为时分秒)

    int second = 0: Handler handler = new Handler(); handler.post(runnable); Runnable runnable = new Run ...

  9. 用 Spark 为 Elasticsearch 导入搜索数据

    越来越健忘了,得记录下自己的操作才行! ES和spark版本: spark-1.6.0-bin-hadoop2.6 Elasticsearch for Apache Hadoop 2.1.2 如果是其 ...

  10. idea Exception in thread "http-apr-8080-exec-2" java.lang.OutOfMemoryError: PermGen space

    idea Exception in thread "http-apr-8080-exec-2" java.lang.OutOfMemoryError: PermGen space ...