hdu 5159 Card (期望)
[Technique specification] All numbers are integers. 1<=T<=500000 1<=x<=100000 1<=b<=5
2 3
3 3
Case #2: 4.222
For the first case, all possible combinations BieBie can pick are (1, 1, 1),(1,1,2),(1,2,1),(1,2,2),(2,1,1),(2,1,2),(2,2,1),(2,2,2)
For (1,1,1),there is only one kind number i.e. 1, so the sum of different score is 1.
However, for (1,2,1), there are two kind numbers i.e. 1 and 2, so the sum of different score is 1+2=3.
So the sums of different score to corresponding combination are 1,3,3,3,3,3,3,2
So the expectation is (1+3+3+3+3+3+3+2)/8=2.625
桌子上有a张牌,每张牌从1到a编号,编号为i(1<=i<=a)的牌上面标记着分数i , 每次从这a张牌中随机抽出一张牌,然后放回,执行b次操作,记第j次取出的牌上面分数是 Sj, 问b次操作后不同种类分数之和的期望是多少。
设Xi代表分数为i的牌在b次操作中是否被选到,Xi=1为选到,Xi=0为未选到
那么期望EX=1*X1+2*X2+3*X3+…+x*Xx
Xi在b次中被选到的概率是1-(1-1/x)^b
那么E(Xi)= 1-(1-1/x)^b
那么EX=1*E(X1)+2*E(X2)+3*E(X3)+…+x*E(Xx)=(1+x)*x/2*(1-(1-1/x)^b)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
double x,b;
int ac=;
while(t--)
{
scanf("%lf%lf",&x,&b);
double ans=;
double p=-pow((-1.0/x),b);
double num=(+x)*x*1.0/;
ans=num*p;
printf("Case #%d: ",++ac);
printf("%.3lf\n",ans);
}
return ;
}
hdu 5159 Card (期望)的更多相关文章
- HDU 5159 Card (概率求期望)
B - Card Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- HDU 5159 Card( 计数 期望 )
Card Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- HDU 5159 Card
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5159 题解: 考虑没一个数的贡献,一个数一次都不出现的次数是(x-1)^b,而总的排列次数是x^b, ...
- HDU 5984 数学期望
对长为L的棒子随机取一点分割两部分,抛弃左边一部分,重复过程,直到长度小于d,问操作次数的期望. 区域赛的题,比较基础的概率论,我记得教材上有道很像的题,对1/len积分,$ln(L)-ln(d)+1 ...
- HDU 4336 Card Collector 期望dp+状压
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4336 Card Collector Time Limit: 2000/1000 MS (Java/O ...
- hdu 4336 Card Collector(期望 dp 状态压缩)
Problem Description In your childhood, people in the famous novel Water Margin, you will win an amaz ...
- HDU 4336 Card Collector:期望dp + 状压
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意: 一共有n种卡片.每买一袋零食,有可能赠送一张卡片,也可能没有. 每一种卡片赠送的概率为p ...
- HDU 4336 Card Collector:状压 + 期望dp
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意: 有n种卡片(n <= 20). 对于每一包方便面,里面有卡片i的概率为p[i],可 ...
- hdu 4336 Card Collector (概率dp+位运算 求期望)
题目链接 Card Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
随机推荐
- UIWebView加载html 图片大小自适应的方法汇总
方法一 处理HTMLString的方法: NSString *htmls = [NSString stringWithFormat:@"<html> \n" " ...
- Android中的windowSoftInputMode属性详解
这篇文章主要介绍了Android中的windowSoftInputMode属性详解,本文对windowSoftInputMode的9个属性做了详细总结,需要的朋友可以参考下 在前面的一篇文章中 ...
- Eclipse 4.2 + Tomcat 7.x + JDK 7 搭建Java Web开发环境
1. 准备工具 Eclipse 4.2 (到官网下载:http://www.eclipse.org/downloads/ 要下载Eclipse IDE for Java EE Developers ...
- Linux常见面试题
一.填空题:1. 在Linux系统中,以 文件 方式访问设备 .2. Linux内核引导时,从文件 /etc/fstab 中读取要加载的文件系统.3. Linux文件系统中每个文件用 索引节点来标 ...
- UI Prototype Design IDE( 界面原型设计工具 )
UI Prototype Design IDE( 界面原型设计工具 ) 如何用工具去与客户进行交流,互动,定义要做的系统,什么什么的... 0.Balsamiq Mockups http://ww ...
- DFBle.swift
//// DFBle.swift// DFBle//// Created by LeeYaping on 15/9/2.// Copyright (c) 2015年 lisper. All r ...
- 在VM中安装Android4.4连接小米手环 之 在VM中安装Android4.4
今天刚买了个小米手环,系统须要4.4及以上,但自己手机系统版本号不匹配.故打算在VM中安装Android4.4连接小米手环. 这一节先介绍在VM中安装Android4.4(怎么安装VM就不介绍了) 1 ...
- Java基础知识强化49:10个实用的但偏执的Java编程技术
1. 将String字符串放在最前面 为了防止偶发性的NullPointerException 异常,我们通常将String放置在equals()函数的左边来实现字符串比较,如下代码: // Bad ...
- 前端 HTML基础
前端三大利器概述 学习前端,不得不学习前端中的三大利器:html + css + javascript.那么这三个组件分别起到什么作用呢?以人体为例,单单具有html属性的人,只是一个裸体的人偶(理解 ...
- eclipse频繁崩溃退出
1.出现下面的崩溃情况,并且改变内存大小都没有用,而且总是生成下面两个错误日志文件: 解决: 在eclipse.ini文件里面添加一行 -XX:-UseLoopPredicate 2.eclipse崩 ...