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 ...
随机推荐
- Ducci Sequence
Description A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers ( ...
- Mvc生命周期深度剖析
客户端发送请求->IIS, UrlRouting模块对比URL, 默认如果该URL能对应到实体文件则退出MVC管道把控制权交还给IIS. 如果RegisterRoutes中的路由规则对比成功默认 ...
- Timeline
Timeline面板 Chrome开发者工具详解(3)-Timeline面板 注: 这一篇主要讲解面板Timeline,参考了Google的相关文档,主要用于公司内部技术分享.. 更新时间:201 ...
- poj City Horizon (线段树+二分离散)
http://poj.org/problem?id=3277 City Horizon Time Limit: 2000MS Memory Limit: 65536K Total Submissi ...
- iOS sqlite 增删改查 简单封装(基于 FMDB)
/** * 对 sqlite 的使用进行简单封装,仅涉及简单的单表 增删改查 * * 基于 FMDB * * 操作基于 model ,数据库表字段与 model 属性一一对应,对 model 整 ...
- linux 安装firefox
从火狐官网下载的firefox-9.0.1.tar.bz2解压后,进入firefox文件夹,执行./firefox会提示缺少库,故采用yum安装Firefox9.1.切换到root用户 su - 2. ...
- EasyUI Datagrid 取编辑修改后的内容
<script type="text/javascript"> $(function () { $('#tt').datagrid({ iconCls: 'icon-e ...
- C/C++语言参数传递----函数/方法 参数的指针引用传递
int m_value = 1; void func(int *p) { p = &m_value; } int main(int argc, char *argv[]) { int n = ...
- mybatis知识点
1.Mybatis比IBatis比较大的几个改进是什么 a.有接口绑定,包括注解绑定sql和xml绑定Sql , b.动态sql由原来的节点配置变成OGNL表达式, c. 在一对一,一对多的时候引进了 ...
- 【转】wireshark过滤规则
WireShark过滤语法 1.过滤IP,如来源IP或者目标IP等于某个IP 例子:ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107或者ip.add ...