杭电2955 Robberies01背包
来源:互联网 发布:广东电信 网络测速 编辑:程序博客网 时间:2024/06/01 21:15
Robberies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 17746 Accepted Submission(s): 6552
Problem Description
The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided to work in the lucrative business of bank robbery only for a short while, before retiring to a comfortable job at a university.
For a few months now, Roy has been assessing the security of various banks and the amount of cash they hold. He wants to make a calculated risk, and grab as much money as possible.
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.
For a few months now, Roy has been assessing the security of various banks and the amount of cash they hold. He wants to make a calculated risk, and grab as much money as possible.
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.
Input
The first line of input gives T, the number of cases. For each scenario, the first line of input gives a floating point number P, the probability Roy needs to be below, and an integer N, the number of banks he has plans for. Then follow N lines, where line j gives an integer Mj and a floating point number Pj .
Bank j contains Mj millions, and the probability of getting caught from robbing it is Pj .
Bank j contains Mj millions, and the probability of getting caught from robbing it is Pj .
Output
For each test case, output a line with the maximum number of millions he can expect to get while the probability of getting caught is less than the limit set.
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.
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.
Sample Input
30.04 31 0.022 0.033 0.050.06 32 0.032 0.033 0.050.10 31 0.032 0.023 0.05
Sample Output
246
Source
IDI Open 2009
Recommend
gaojie | We have carefully selected several similar problems for you: 2844 1864 1087 1505 1176
01 背包:
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int gett[11000],i,j,k,l,m,n;double cost[11000],all,ans[11000];int main(){scanf("%d",&k);while(k--){memset(ans,0,sizeof(ans));scanf("%lf%d",&all,&m);all=1-all;int sum=0;for(i=1;i<=m;i++){scanf("%d%lf",&gett[i],&cost[i]);cost[i]=1-cost[i];sum+=gett[i];}ans[0]=1;l=0;for(i=1;i<=m;i++)for(j=sum;j>=gett[i];j--)ans[j]=max(ans[j],ans[j-gett[i]]*cost[i]);//代表得到j的情况下 for(i=sum;i>=0;i--)//最大的可能逃跑的概率if(ans[i]>=all){printf("%d\n",i);break;}}}
0 0
- 杭电2955 Robberies01背包
- 杭电2955Robberies(01背包)
- 杭电2955-0-1背包
- 杭电1248-背包
- 杭电 2602 01 背包
- 杭电2159背包问题!
- 杭电1712--分组背包。。
- 杭电1494---01背包。
- 杭电1114 完全背包
- 杭电2602---01背包
- 杭电1114--完全背包
- 杭电1963 完全背包
- 杭电1059-多重背包
- 【杭电2602】01背包
- 【杭电3466】贪心+背包
- 【杭电1114】完全背包
- 杭电2955题解题报告及01背包问题
- 杭电1171(一维背包+完全背包)
- ActionScript 3.0 学习(十四) 从加载的.swf文件中读取flash库中的as链接的类
- Jenkins的分布式构建
- 类与对象编程题3(C++程序设计第3周)
- 常用的几种数据库介绍
- Android在View onCreate时获取控件的宽和高
- 杭电2955 Robberies01背包
- C++中的istringstream 的用法
- 二维向量vector の 邪恶的多维数组 (二) 降维
- UML之总结
- UESTC 1264 人民币的构造 数论
- Word Pattern
- XML解析
- E - 胜利大逃亡(续) hdu 1429
- Java中Runtime和Properties