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/ ...
随机推荐
- Bootstrap 只读输入框
只读输入框 为输入框设置 readonly 属性可以禁止用户输入,并且输入框的样式也是禁用状态. <input class="form-control" type=&qu ...
- 排序系列 之 堆排序算法 —— Java实现
基本概念: 二叉堆是完全二叉树或者是近似完全二叉树. 当父结点的键值总是大于或等于任何一个子节点的键值时为最大堆. 当父结点的键值总是小于或等于任何一个子节点的键值时为最小堆. 一般将二叉堆简称 ...
- PCB MongoDb安装与Windows服务安装
工程MI流程指示做成Web网页形式,采用MVC框架制作,数据传输用Web API方式, 最终此网页会挂到公司各系统中访问,为了提高访问并发量,并将工程数据统一结构化管理, 采用No SQL Mongo ...
- Python 40 数据库-外键约束 、多对一与多对多的处理
mysql提供了 foreign key,专门用于为表和表之间 建立物理关联 思考 表里存储的是一条条的记录,两个表之间能产生的关系有哪些? 现有 A B两张表 1.多对一 2.一对一 ...
- java.util.Date
package com.etc.usual; import java.util.Calendar; import java.util.Date; /** * * @author Administrat ...
- 运用<body>属性,渲染页面效果
新建一个HTML5文件,为<body>标签添加样式,代码如下: 01 <!doctype html> 02 <html> 03 <head> 04 &l ...
- 171129-workaround on ubuntu-seting up piston for steem
setup ubuntu environment variables sudo vi /etc/environment Then set all below variables: percentCha ...
- creat-react-app 支持 less
yarn eject yarn add less less-loader config/ webpack.config.dev.js config/ webpack.config.prod.js 文 ...
- WEB笔记-CSS 实现多级导航效果
代码如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...
- 【VB】时间戳转日期
DateAdd("s", TimeStamp / 1000, "1970-01-01 00:00:00")