hdu 4586 Play the Dice (概率+等比数列)
Play the Dice
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1328 Accepted Submission(s): 429
Special Judge
yuan. What's more, some sids of this dice are colored with a special different color. If you turn this side up, you will get once more chance to roll the dice. When you roll the dice for the second time, you still have the opportunity to win money and rolling
chance. Now you need to calculate the expectations of money that we get after playing the game once.
The first line is an integer n (2<=n<=200), following with n integers ai(0<=ai<200)
The second line is an integer m (0<=m<=n), following with m integers bi(1<=bi<=n), which are the numbers of the special sides to get another more chance.
6 1 2 3 4 5 6
0
4 0 0 0 0
1 3
3.50
0.00
思路:刚開始理解错题意了,老感觉那m个面的数字的大小和结果有关。
事实上,掷到一个特殊面仅仅是得到了一个再次投掷的机会,和第一次投掷的效果全然一样。
sum=a1+a2+...+an; a=sum/n; q=m/n;
ans=a+a*q+a*q^2+...=sum/(n-m);
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
#define N 205
const int inf=0x3fffffff;
int a[N];
int main()
{
int i,n,m,t;
double sum;
while(scanf("%d",&n)!=-1)
{
sum=0;
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
scanf("%d",&m);
for(i=0;i<m;i++)
{
scanf("%d",&t);
}
if(sum==0)
{
printf("0.00\n");
continue;
}
if(m==n)
{
printf("inf\n");
continue;
}
printf("%.2f\n",sum/(n-m));
}
return 0;
}
hdu 4586 Play the Dice (概率+等比数列)的更多相关文章
- 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 ...
- 概率DP HDU 4586 play the dice
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4586 解题思路: 只考虑第一次,获得的金币的平均值为sum/n.sum为所有色子的面的金币值相加. ...
- HDU 4586 Play the Dice (数学,概率,等比公式,极限)
题意:给你一个n面的骰子每个面有一个值,然后其中有不同值代表你能获得的钱,然后有m个特殊的面,当你骰到这一面的时候可以获得一个新的机会 问你能得到钱的期望. 析: 骰第一次 sum/n 骰第二 ...
- 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
思路:设期望值为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: 当 ...
- 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/ ...
随机推荐
- warning: here-document at line 7 delimited by end-of-file (wanted `rui')
- python对XML 操作
一.XML的读取. 在 NewEdit 中有代码片段的功能,代码片段分为片段的分类和片段的内容.在缺省情况下都是用XML格式保存的.下面我讲述一下,如何使用minidom来读取和保存XML文件. 下面 ...
- E20170826-hm
squash vt. 挤进; 将(某人[某物])压扁; 使沉默; 平定(叛乱等); meld vt. (使) 融合,合并,结合; n. 混合,合并; amend vt. 修订; 改良,修改; a ...
- 七牛php上传下载类,集成官方文档的方法
<?phpuse Qiniu\Auth;use Qiniu\Storage\UploadManager;class qiniu{ public $_accesskey = null; publi ...
- javaweb 课程设计编码和设计文档
企业办公软件设计文档 1引言 1.1编写目的 OA办公自动化系统详细设计是设计的第三个阶段,这个阶段的主要任务是在OA办公自动化系统概要设计书基础上,对概要设计中产生的功能模块进行过程描述,设计功能模 ...
- [转]rdlc报表中表达式的使用--switch和IIF范例
本文转自:http://hi.baidu.com/oypx1234/item/5b35dec4e03a3ad697445266 =Switch( Fields!MLWHLO.Value = " ...
- django-2的路由层(URLconf)
URL配置(URLconf)就像Django 所支撑网站的目录.它的本质是URL与要为该URL调用的视图函数之间的映射表:你就是以这种方式告诉Django,对于客户端发来的某个URL调用哪一段逻辑代码 ...
- 自学Python五 爬虫基础练习之SmartQQ协议
BAT站在中国互联网的顶端,引导着中国互联网的发展走向...既受到了多数程序员的关注,也在被我们所惦记着... 关于SmartQQ的协议来自HexBlog,根据他的博客我自己也一步一步的去分析,去尝试 ...
- 苹果双系统win8.1遇到的一些问题
MacBook air是一款不错的电脑,详细没研究就不叙述好与坏了.只此记录自己使用这款笔记本遇到的问题. 一.安装双系统win8.1 1.下载镜像文件—>拷贝到ios内存中,一个8GU盘.ht ...
- 如何使windows系统ping通VMware下面的linux系统
引用http://www.linuxidc.com/Linux/2012-11/73749p2.htm 很多人在开始接触Linux或者是嵌入式开发的时候都会遇到一个难题,就是如何在Linux下ping ...