hdu 4586 Play the Dice
思路:设期望值为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的更多相关文章
- 概率DP HDU 4586 play the dice
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4586 解题思路: 只考虑第一次,获得的金币的平均值为sum/n.sum为所有色子的面的金币值相加. ...
- 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(概率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(数学期望)
Play the Dice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tot ...
- 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 骰第二 ...
- HDU 5955 Guessing the Dice Roll
HDU 5955 Guessing the Dice Roll 2016 ACM/ICPC 亚洲区沈阳站 题意 有\(N\le 10\)个人,每个猜一个长度为\(L \le 10\)的由\(1-6\) ...
- hdu 5955 Guessing the Dice Roll 【AC自动机+高斯消元】
hdu 5955 Guessing the Dice Roll [AC自动机+高斯消元] 题意:给出 n≤10 个长为 L≤10 的串,每次丢一个骰子,先出现的串赢,问获胜概率. 题解:裸的AC自动机 ...
- HDU 4586 A - Play the Dice 找规律
A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
随机推荐
- bzoj 1009:[HNOI2008]GT考试
这道题机房n多人好久之前就A了…… 我到现在才做出来…… 一看就是DP+矩阵乘法,但是一开始递推式推错了…… 正确的递推式应该是二维的…… f[i][j] 表示第准考证到第 i 位匹配了 j 位的方案 ...
- 用户输入内容转换成Pig Latin形式。
//(单词的第一个元音字母之前的一道单词后面,以"ay"结尾,英语单词首字母为元音字母或者没有元音字母的以“ay”为后缀.)package toPigLatin; import j ...
- VKP5 Price Calculation – List Variant & KZPBL (Delete site level)
List Variant: Configuration in Logistic General –> Retail Pricing –> Sales Price Calculation – ...
- EF6数据迁移
当Moldes发生改变时 会提示数据上下文的模型已在数据库创建后发生改变,则需要重建数据库并数据迁移 在NuGet程序包管理控制台输入enable-migrations启用数据迁移 之后会提示&quo ...
- .NET中变量的类型问题
1.JAVA和C# Byte的不同. java里一个byte取值范围是-128~127, 而C#里一个byte是0~255. 首位不同. 但是底层I/O存储的数据是一样的, 比如, 十进制的100, ...
- 《samba服务配置的文本》
创建简单的samba服务器 samba 很少用于互联网 /大部分用于局域网 网页更新/ 首先看下你是否安装后了samba. rpm -qa | grep samba samba的简介 1)samb ...
- ArcGIS API for JavaScript介绍
ArcGIS API for JavaScript中的类是按照模块组织的,主要包含esri.esri/geometry.esri/renderers.esri/symbols.esri/symbols ...
- AngularJS(16)-路由
AngularJS 路由 本章节我们将为大家介绍 AngularJS 路由. AngularJS 路由允许我们通过不同的 URL 访问不同的内容. 通过 AngularJS 可以实现多视图的单页Web ...
- fast_recovery_area无剩余空间(ORA-19815)
一.问题现象 --执行日志切换时,夯住 SQL ('/u01/oradata/oracle/redo04.log') size 50m; SQL> alter system switch log ...
- Python开发【第一篇】Python基础之函数递归
函数递归 递归的本质: 就是一个函数调用另外一个函数. def d(): return '123' def c(): r = d() return r def b(): r = c() return ...