思路:设期望值为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. UILabel滚动字幕的实现

    经常需要在应用中显示一段很长的文字,比如天气或者广告等,这时候使用滚动字幕的方式比较方便. 参考文献: [1] YouXianMing, 使用UILabel实现滚动字幕移动效果, 博客园 [2] ht ...

  2. uniform 中checkbox通过jquery 选中

    你是否曾经为不能修改多选框.单选框.文件选择框的样式而郁闷呢,是否想过控制它们的样式且兼容所有浏览器呢?我现在给你推荐的这个jQuery表单美化插件Uniform就可以解决这些问题. Uniform可 ...

  3. seajs构建方法

    标准构建 如果项目遵循推荐的标准目录结构: foo-module/   |-- dist                    //存放构建好的文件   |-- src                 ...

  4. java之javadoc命令

    [javadoc命令的用法] 1.java源文件里,注释以/**开始 并以*/结束,里面可以包含普通文件,HTML标记和javaDoc标记.这些将构成javaDoc文档. 2.javadoc命令只能处 ...

  5. raiserror的用法

    描述:raiserror :是用于抛出一个错误 第一个参数:{ msg_id | msg_str | @local_variable } msg_id:表示可以是一个sys.messages表中定义的 ...

  6. putty工具常见设置

    Putty 工具主要是用于在 windows 环境下连接 linux 服务器的一个命令行工具,可以在此客户端中进行编译.svn代码修改 更新 提交等动作.LD主要是用它来干这个的. 工作环境的改变: ...

  7. windows2003服务器不显示桌面怎么办

    ctrl +alt+delete 进入任务管理器应用程序里 创建新任务 C:\WINDOWS\explorer.exe 运行就行

  8. How To Fix – Mcrypt PHP extension required in Laravel on Mac OS X (No MAMP)

    Laravel PHP web framework requires certain libraries to function properly. One of these libraries is ...

  9. C预处理,条件编译

    预处理是指在编译器之前运行,常以“#”开头 包含3个方面的内容: 1)宏定义与宏替换 2)文件包含 3)条件编译 宏定义与宏替换: 宏名一般大写,替换发生在编译之前,且是机械替换,不做语法检查,也不分 ...

  10. NOIP2015-stone(二分答案)

    这道题在考试时二分答案写炸了,结果得了20分.....同学有用贪心写的(对,贪心!!)都得了30,我感到了深深的恶意.这段时间在忙转语言,现在重新整理一下NOIP的题. 题目来源:vijos 题目如下 ...