题目链接:

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. Codeforces 197D - Infinite Maze

    197D - Infinite Maze 思路:bfs,如果一个点被搜到第二次,那么就是符合要求的. 用vis[i][j].x,vis[i][j].y表示i,j(i,j是取模过后的值)这个点第一次被搜 ...

  2. Unity 中 ContextMenu 的用法

    在自定义脚本中的方法前加入  [ContextMenu("Execute")]  标签,然后将脚本挂载到对象上,可以再编辑模式下执行标记的方法: 自定义脚本如下: using Sy ...

  3. Java读写记事本文件

    Java中我们也会考虑读写记事本,文件读取如下: public static void main(String[] args) { try { String path="d:\\abc.tx ...

  4. C#读写记事本(txt)文件

    C#写入记事本(txt)文件方法一: FileStream stream = new FileStream(@"d:\aa.txt",FileMode.Create);//file ...

  5. English trip -- VC(情景课)8 D Reading

    Listen and read. Shop Smart [smɑːt]  Employee of the Month: Sara['særə] (萨拉) Lopez(洛佩斯) Congratulati ...

  6. Almost Acyclic Graph CodeForces - 915D (思维,图论)

    大意: 给定无向图, 求是否能删除一条边后使图无环 直接枚举边判环复杂度过大, 实际上删除一条边可以看做将该边从一个顶点上拿开, 直接枚举顶点即可 复杂度$O(n(n+m))$ #include &l ...

  7. python-day49--前端 html

    一.列表标签 1.有序列表 <ol>       (order list ) 在浏览器中显示包括:padding , 有序排列     <li>:列表中的每一项. 2.无序列表 ...

  8. android升级adt和sdk之后无法识别SDK Location的一个解决方式

    我把android的adt和sdk从4.0升级到4.2,发现eclipse的android设置里面原来列出的各种api level的platform消失了,而且无法新建android工程.而且检查过了 ...

  9. 贴心的vs 备注提醒功能

  10. 自定义Spark Partitioner提升es-hadoop Bulk效率

    http://www.jianshu.com/p/cccc56e39429/comments/2022782 和 https://github.com/elastic/elasticsearch-ha ...