抢银行 扭向0 1
来源:互联网 发布:主播音效软件 编辑:程序博客网 时间:2024/05/01 00:48
Problem V
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 24 Accepted Submission(s) : 8
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.<br><br><center><img src=../../../data/images/con211-1010-1.jpg></center> <br>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.<br><br><br>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 . <br>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.<br><br>Notes and Constraints<br> 0 < T <= 100<br> 0.0 <= P <= 1.0<br> 0 < N <= 100<br> 0 < Mj <= 100<br> 0.0 <= Pj <= 1.0<br> 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
关于抢银行的问题
上来先把失败全部转化为成功的概率
然后逆向dp
对所有的 价钱
分别求出抢到这个价钱最大成功概率
抢到这个价钱的概率
最后 取出 钱数最大概率能成功的 案例
#include<iostream>#include<string.h>#include<set>#include<stdio.h>#include<vector>#include<algorithm>#include<numeric>#include<math.h>#include<string.h>#include<sstream>#include<stdio.h>#include<string>#include<cstdlib>#include<algorithm>#include<iostream>#include<map>#include<queue>#include<iomanip>#include<cstdio>using namespace std;double pao[10000];int a[10000];double b[10000];int main(){ int t; scanf("%d",&t); while(t--) { memset(pao,0,sizeof(pao)); pao[0]=1; double t; int x; scanf("%lf %d",&t,&x); t=1-t; int i,j; int sum=0; for(i=1;i<=x;i++) { scanf("%d%lf",&a[i],&b[i]); b[i]=1-b[i]; sum=sum+a[i]; } for(i=1;i<=x;i++) { for(j=sum;j>=a[i];j--) { if(pao[j]<pao[j-a[i]]*b[i]) { pao[j]=pao[j-a[i]]*b[i]; } } } for(i=sum;i>=0;i--) { if((pao[i]-t)>0.000000001) {cout<<i<<endl; break; } } } return 0;}
0 0
- 抢银行 扭向0 1
- hdu2955 0-1背包变形 抢银行
- java编程题:100个线程同时向一个银行账户中存入1元钱
- 利用线程同步模拟一人向银行存钱,一人从银行取钱。
- web service实例(向银行服务支付金额)
- 转:创业团队需要向银行劫匪学习什么?
- mfc 模仿键盘按键向银行密码控件输入密码
- 印度最高法院向储备银行发布比特币监管通知
- 抢银行日记
- 抢银行日记
- 银行系统(1)
- 银行系统(1)
- 银行
- 银行
- 银行
- 银行
- 银行
- 银行
- 【追求进步】数组中重复的数字
- 多线程
- 如何优雅的使用 Mac
- 7.PHP中的运算符2
- 移植gdb工具-远程调试qt程序
- 抢银行 扭向0 1
- 文章标题
- Java 多线程编程学习(二)
- mojo 接口返回键值对的json格式
- windows下code::blocks与Qt编译环境搭建
- ARM920T及其MMU,Cache学习杂记(一)
- 手机发送验证码验证Verification.rb表详解
- 二叉树之中序遍历的递归和迭代实现
- 8.PHP中原码反码介绍及位运算符应用