hduoj 2955Robberies
Robberies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 16726 Accepted Submission(s): 6165

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.
0.04 3
1 0.02
2 0.03
3 0.05
0.06 3
2 0.03
2 0.03
3 0.05
0.10 3
1 0.03
2 0.02
3 0.05
4
6
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 1e-8
int cost[];
double p[],dp[];
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int t,bn,i,sum;
double pro;
scanf("%d",&t);
while(t--){
sum=;
//memset(dp,0,sizeof(dp));
scanf("%lf %d",&pro,&bn);
pro=-pro;//不被抓的概率大于才有效
for(i=;i<bn;i++){
scanf("%d %lf",&cost[i],&p[i]);
sum+=cost[i];
p[i]=-p[i];
}
for(i=;i<=sum;i++){
dp[i]=;
}
dp[]=;
int j;
for(i=;i<bn;i++){
for(j=sum;j>=cost[i];j--){
//得到j钱,最大的不被抓的可能性
dp[j]=max(dp[j],dp[j-cost[i]]*p[i]);
}
}
for(j=sum;j>=;j--){
if(dp[j]-pro>inf){
break;
}
}
printf("%d\n",j);
}
return ;
}
hduoj 2955Robberies的更多相关文章
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...
- hdu-oj 1874 畅通工程续
最短路基础 这个题目hdu-oj 1874可以用来练习最短路的一些算法. Dijkstra 无优化版本 #include<cstdio> #include<iostream> ...
- C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...
- C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...
- HDUOJ题目HTML的爬取
HDUOJ题目HTML的爬取 封装好的exe/app的GitHub地址:https://github.com/Rhythmicc/HDUHTML 按照系统选择即可. 其实没什么难度,先爬下来一个题目的 ...
- hduoj 1251 统计难题
http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory ...
- hduoj 1286 找新朋友
http://acm.hdu.edu.cn/showproblem.php?pid=1286 找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
随机推荐
- HTML完全使用详解 PDF扫描版
<HTML完全使用详解>根据网页制作的实际特点和目前市场需要,全面系统地介绍了最新的HTML4.01.丰富的实例贯穿全书,能帮助您全面掌握HTML,而且本书所有实例均可直接修改使用,可以提 ...
- Binder学习笔记(十一)—— 智能指针
轻量级指针 Binder的学习历程爬到驱动的半山腰明显感觉越来越陡峭,停下业务层的学习,补补基础层知识吧,这首当其冲的就是智能指针了,智能指针的影子在Android源码中随处可见.打开framewor ...
- XCode9: iPhone is busy: Preparing debugger support for iPhone
这个好像是等一阵子就可以了 参考链接
- How to publish a pointcloud of ros msgs in a topic from a pcd file?
How to publish a pointcloud of ros msgs in a topic from a pcd file? Two methods 1. modified source 2 ...
- wget使用技巧
以下内容为转载: wget 是一个命令行的下载工具.对于我们这些 Linux 用户来说,几乎每天都在使用它.下面为大家介绍几个有用的 wget 小技巧,可以让你更加高效而灵活的使用 wget. $ w ...
- 配置vuex并使用
配置vuex并使用 安装vuex: npm install --save-dev vuex 在src目录下创建store文件夹 store文件夹下文件 index.js,state.js,getter ...
- 【NOIP 2015】斗地主
题目描述 牛牛最近迷上了一种叫斗地主的扑克游戏.斗地主是一种使用黑桃.红心.梅花.方片的 A 到 K 加上大小王的共 54 张牌来进行的扑克牌游戏.在斗地主中,牌的大小关 系根据牌的数码表示如下: 3 ...
- Kbuild、Kconfig、make menuconfig、.config、Makefile之间的关系
今天突发奇想,想在这里分享下比喻分析Kbuild ---->去饭店吃饭的过程. 1.Kconfig --->饭店的菜单 2.条件编译选项--->菜单中的每一盘菜,可以选择这个菜的 ...
- zookeeper客户端使用第三方(Curator)封装的Api操作节点
1.为什么使用Curator? Curator本身是Netflix公司开源的zookeeper客户端: Curator 提供了各种应用场景的实现封装: curator-framework 提供了f ...
- Qt 学习之路 2(15):标准对话框 QMessageBox
Qt 学习之路 2(15):标准对话框 QMessageBox 豆子 2012年9月18日 Qt 学习之路 2 40条评论 所谓标准对话框,是 Qt 内置的一系列对话框,用于简化开发.事实上, ...