思路:设期望值为s,前m个是再来一次机会,则有

s=(a[1]+s)/n+(a[2]+s)/n+……+(a[m]+s)/n+a[m+1]/n……

化简:(n-m)s=sum

当sum=0时,为0;

当n==m时,为inf;

否则为sum/(n-m).

代码如下:

 #include<cstdio>
#define I(x) scanf("%d",&x)
int main()
{
int n,m,t,sum;
while(I(n)!=EOF){
sum=;
for(int i=;i<n;i++){
I(t);
sum+=t;
}
I(m);
for(int i=;i<m;i++) I(t);
if(sum==) printf("0.00\n");
else if(n==m) printf("inf\n");
else printf("%.2lf\n",1.0*sum/(n-m));
}
return ;
}

hdu 4586 Play the Dice的更多相关文章

  1. 概率DP HDU 4586 play the dice

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4586 解题思路: 只考虑第一次,获得的金币的平均值为sum/n.sum为所有色子的面的金币值相加. ...

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

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

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

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

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

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

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

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

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

  7. HDU 5955 Guessing the Dice Roll

    HDU 5955 Guessing the Dice Roll 2016 ACM/ICPC 亚洲区沈阳站 题意 有\(N\le 10\)个人,每个猜一个长度为\(L \le 10\)的由\(1-6\) ...

  8. hdu 5955 Guessing the Dice Roll 【AC自动机+高斯消元】

    hdu 5955 Guessing the Dice Roll [AC自动机+高斯消元] 题意:给出 n≤10 个长为 L≤10 的串,每次丢一个骰子,先出现的串赢,问获胜概率. 题解:裸的AC自动机 ...

  9. HDU 4586 A - Play the Dice 找规律

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

随机推荐

  1. IOS基础之设置APP的名字、设置图标、添加等待加载时的图片

    1.我们的app一般默认的名字是我们的工程名字,所以我们一般会更改一个更加友好的名字,更改的方法如下图: 找到InfoPlist.strings文件,在里面添加语句CFBundleDisplayNam ...

  2. 如何将HDL文件实例化到XPS中

     本文转载自:http://xilinx.eetrend.com/blog/7073 硬件平台:ZedBoard 开发环境:XPS + ISE 操作系统:WinXP SP3 一直说要研究官方的例子 ...

  3. (原创)LINUX_UNIX设计思想-读书笔记

    第一章 一.Unit哲学 1.小即是美 2.让每一个程序只做好一件事情 3.尽快建立原型 4.舍高效率而取可移植性 5.使用纯文本文件来存储数据 6.充分利用软件的杠杆效应 7.使用shell脚本来提 ...

  4. 每日一“酷”之copy

    Copy – 复制对象 作用:提供一些函数,可以使用浅副本或深副本语义复制对象. copy模块包括两个函数copy()和deepcopy(),用于复制现有的对象 1.  浅副本 copy()创建的浅副 ...

  5. WPF 一个弧形手势提示动画

    这是一个操作提示动画,一个小手在屏幕上按照一个弧形来回运动 <Window x:Class="LZRichMediaWall.MainWindow" xmlns=" ...

  6. JMS消息头

    一个消息对象分为三部分:消息头(Headers),属性(Properties)和消息体(Payload).对于StreamMessage和MapMessage,消息本身就有特定的结构,而对于TextM ...

  7. HDFS基本知识整理

    设计理念:         1.超大文件         2.流式数据访问         3.商用普通硬件 不适合场景:         1.低时间延迟的数据访问         2.大量的小文件 ...

  8. 从零开始学ios开发(十二):Table Views(中)UITableViewCell定制

    我们继续学习Table View的内容,这次主要是针对UITableViewCell,在前一篇的例子中我们已经使用过UITableViewCell,一个默认的UITableViewCell包含imag ...

  9. [转载]iOS面试题总

    转载自:http://blog.sina.com.cn/s/blog_67eb608b0101r6xb.html (2014-06-13 20:23:33) 转载▼ 标签: 转载   crash 原文 ...

  10. Get current time and date on Android

    You could use: Calendar c =Calendar.getInstance();int seconds = c.get(Calendar.SECOND); There are pl ...