hdu4336 Card Collector
As a smart boy, you notice that to win the award, you must buy much more snacks than it seems to be. To convince your friends not to waste money any more, you should find the expected number of snacks one should buy to collect a full suit of cards.
Note there is at most one card in a bag of snacks. And it is possible that there is nothing in the bag.
You will get accepted if the difference between your answer and the standard answer is no more that 10^-4.
#include<cstdio> int main()
{
int n;
double a[];
while (~scanf("%d",&n))
{
for (int i=;i<n;++i)
scanf("%lf",&a[i]);
double temp,ans=;
for (int i=;i< (<<n);++i)
{
temp=;
int ct=;
for (int j=;j<n;++j)
if (i & (<<(j) ) )
{
ct++;
temp+=a[j];
}
if (ct & ) ans+=/temp;
else ans-=/temp;
}
printf("%.4f\n",ans);
}
return ;
}
hdu4336 Card Collector的更多相关文章
- hdu4336 Card Collector 状态压缩dp
Card Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- [HDU4336]Card Collector(min-max容斥,最值反演)
Card Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu4336 Card Collector 【最值反演】
题目链接 hdu4336 题解 最值反演 也叫做\(min-max\)容斥,在计算期望时有奇效 \[max\{S\} = \sum\limits_{T \in S} (-1)^{|T| + 1}min ...
- hdu4336 Card Collector(概率DP,状态压缩)
In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, fo ...
- hdu4336 Card Collector MinMax 容斥
题目传送门 https://vjudge.net/problem/HDU-4336 http://acm.hdu.edu.cn/showproblem.php?pid=4336 题解 minmax 容 ...
- hdu4336 Card Collector 概率dp(或容斥原理?)
题意: 买东西集齐全套卡片赢大奖.每个包装袋里面有一张卡片或者没有. 已知每种卡片出现的概率 p[i],以及所有的卡片种类的数量 n(1<=n<=20). 问集齐卡片需要买东西的数量的期望 ...
- HDU-4336 Card Collector 概率DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意:买食品收集n个卡片,每个卡片的概率分别是pi,且Σp[i]<=1,求收集n个卡片需要 ...
- hdu4336 Card Collector 容斥原理
In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, fo ...
- HDU4336 Card Collector(期望 状压 MinMax容斥)
题意 题目链接 \(N\)个物品,每次得到第\(i\)个物品的概率为\(p_i\),而且有可能什么也得不到,问期望多少次能收集到全部\(N\)个物品 Sol 最直观的做法是直接状压,设\(f[sta] ...
随机推荐
- Work 3(工作类) (2017.07.01)
- IDEA+Java:Selenium+Maven+TestNG基本WebUI自动化测试环境搭建
IDEA+java:Selenium+Maven+TestNG 本文介绍的测试环境,应该是最基本的测试环境了,也是很多文章都有写,这里做一个完整的图文配置整理,方便阅读理解! 使用maven的好处,由 ...
- (转)TCP和UDP之间的区别
TCP和UDP区别 TCP UDP 是否连接 面向连接 面向非连接 传输可靠性 可靠的 不可靠的 应用场合 传输大量的数据 少量数据 速度 慢 快 OSI 和 TCP/IP 模型在传输层 ...
- C语言基础 - 输出1-100万之间的素数
其实这个很简单 代码 网上也一大堆... //判断素数 BOOL isPrime(int num) { for (int i = 2; i <= sqrt(num); i++) { //能整除则 ...
- 有关java 8
http://www.iteye.com/news/27608 Java 8 发布时间敲定,延期半年 http://www.iteye.com/news/24631/ Java 8 的重要 ...
- Java GC - 监控回收行为与日志分析
1. 简介 在上一篇介绍<Java GC - 垃圾回收机制>, 本文将介绍如何监控 Javc GC 行为,同时涉及一些GUI工具的使用(虽然有些已经很老并不再更新),监控GC在于判断JVM ...
- Java基础之TCP与UDP
OSI 7层参考模型 物理层 --> 数据链路层 --> 网络层 --> 传输层 --> 会话层 --> 表示层 --> 应用层 按此顺序称为拆包,反之为封包. T ...
- HDU 6043 KazaQ's Socks (规律)
Description KazaQ wears socks everyday. At the beginning, he has nn pairs of socks numbered from 11 ...
- 笔记本电脑连接上WiFi后,弹不出登录界面怎么办?
以CMCC为例子 步骤: 1 连接成功CMCC之后,打开适配器设置.右击无线网卡,选择属性 2.双击INTERNET协议版本4 3.将DNS改成自动获取,然后确定 4.再确定 5.然后重新断开CMCC ...
- UE4 C++ 跳转网页
FString TheURL = "https://home.cnblogs.com/u/huojiaoqingchun0123/"; FPlatformProcess::Laun ...