hdu 2955 Robberies
Robberies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7351 Accepted Submission(s): 2762

His mother, Ola, has decided upon a tolerable probability of getting caught. She feels that he is safe enough if the banks he robs together give a probability less than this.
Notes and Constraints 0 < T <= 100 0.0 <= P <= 1.0 0 < N <= 100 0 < Mj <= 100 0.0 <= Pj <= 1.0 A bank goes bankrupt if it is robbed, and you may assume that all probabilities are independent as the police have very low funds.
// 好吧、我对概率真的好弱智 我开始居然是把概率相加了、、、
// 这种情况、为了避开繁杂的讨论 就是利用补集来算了、对立算起来真心更清爽、然后就是O 1 背包了
#include <iostream>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
double dp[];
int M[];
double p[];
#define epx 0.000000001
int main()
{
int T,n,V;
double P;
int i,j,k;
scanf("%d",&T);
while(T--){
scanf("%lf %d",&P,&n);
V=;
for(i=;i<=n;i++)
{
scanf("%d %lf",&M[i],&p[i]);
V+=M[i];
}
for(i=;i<=V;i++)
dp[i]=;
dp[]=;
for(i=;i<=n;i++)
for(j=V;j>=M[i];j--){
if(dp[j]<dp[j-M[i]]*(-p[i]))
dp[j]=dp[j-M[i]]*(-p[i]);
}
P=-P;
for(i=V;i>;i--)
if(dp[i]>=P)
break;
printf("%d\n",i);
} return ;
}
hdu 2955 Robberies的更多相关文章
- HDU 2955 Robberies 背包概率DP
A - Robberies Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submi ...
- [HDU 2955]Robberies (动态规划)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2955 题意是给你一个概率P,和N个银行 现在要去偷钱,在每个银行可以偷到m块钱,但是有p的概率被抓 问 ...
- HDU 2955 Robberies(DP)
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=2955 题目: Problem Description The aspiring Roy the Rob ...
- hdu 2955 Robberies (01背包)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2955 思路:一开始看急了,以为概率是直接相加的,wa了无数发,这道题目给的是被抓的概率,我们应该先求出总的 ...
- HDU 2955 Robberies(0-1背包)
http://acm.hdu.edu.cn/showproblem.php?pid=2955 题意:一个抢劫犯要去抢劫银行,给出了几家银行的资金和被抓概率,要求在被抓概率不大于给出的被抓概率的情况下, ...
- Hdu 2955 Robberies 0/1背包
Robberies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- hdu 2955 Robberies 0-1背包/概率初始化
/*Robberies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- hdu 2955 Robberies 背包DP
Robberies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU 2955 Robberies(01背包)
Robberies Problem Description The aspiring Roy the Robber has seen a lot of American movies, and kno ...
随机推荐
- 第一章 基本的SQL语句 (SQL基础)
1. 查询数据库系统时间,常以服务器默认的格式进行显示(根据数据库的字符集而定): 注意:dual 为数据库中的虚表,隶属于管理员 sys 用户,但所有的用户都可以访问:无实际意义,仅充当select ...
- go语言使用protobuf
网上为什么充斥着大量几乎一模一样而且不正确的教程??? 妈的打开一个关于golang和protobuf的教程,无非都是protobuf多么多么牛逼,xml多么多么傻逼,然后就是怎么安装protobuf ...
- 操作数据(insert、update、delete)
插入数据 使用Insert Into 插入 if(exists(select * from sys.databases where name = 'webDB')) drop database web ...
- Linux 配置Samba
配置Samba 如果没有普通用户,添加用户,指令: useradd -m aaa passwd bbb 添加Samba用户指令: smbpasswd -a aaa passwdword: …… 修改配 ...
- Qt的gzip模块实现
一直没找到Qt中方便的gzip模块,于是自己动手,调用zlib模块实现了一份. 目标: 1.gzip的压缩与解压 2.内存中操作 3.方便的Qt接口 实现分析: gzip 压缩算法为 defla ...
- 浅淡Windows7 32位与64位/x86与x64的区别
看到有很多会员问到底是选Windows7 x86,还是选x64.这里简单的谈一下这这两种系统的区别. 简单的说x86代表32位操作系统 x64代表64位操作系统. 简单的判断电脑是否支持64位操作系 ...
- hdu 4726
贪心 不是很难 各种细节注意 #include <cstdio> #include <cstring> #include <algorithm> using na ...
- Samza的ApplicationMaster
当Samza ApplicationMaster启动时,它做以下的事情: 通过STREAMING_CONFIG环境变量从YARN获取配置信息(configuration) 在随机端口上 启动一个JMX ...
- POJ1416——Shredding Company(DFS)
Shredding Company DescriptionYou have just been put in charge of developing a new shredder for the S ...
- xml--通过jdom解析及生产XML
JDOM是一种使用 XML 的独特 Java 工具包,用于快速开发 XML 应用程序.它的设计包含 Java 语言的语法乃至语义. JAXP (用于 XML 语法分析的 Java API)包含了三个软 ...