题意:给定一个人抢劫每个银行的被抓的概率和该银行的钱数,问你在他在不被抓的情况下,能抢劫的最多数量. 析:01背包,用钱数作背包容量,dp[j] = max(dp[j], dp[j-a[i] * (1.0 - pp[i])),dp[i] 表示不被抓的最大概率,在能抢劫到 i 个钱. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <stri…
Description As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (he wants everything quick!) so he decided to rob banks. He wants to make a calculated risk, and grab as much money as possible. But his friends - Hermi…
题目链接 题意:Harry Potter要去抢银行(wtf???),有n个银行,对于每个银行,抢的话,能抢到Mi单位的钱,并有pi的概率被抓到.在各个银行被抓到是独立事件.总的被抓到的概率不能超过P. 解题关键:如果考虑各种情况存在某一次被抓住的概率,相当于是取 并集,这个比较麻烦.然而,n个独立事件都不被抓住的概率,相当于是取 交集,直接把要考虑到的事件的不被抓住的概率乘到一起就好了.这样就能把这道题转化为01背包的问题了. 不被抓概率!~物品体积 (不被抓概率不低于某阈值,物品总体积不高于某…
题目链接:https://vjudge.net/problem/LightOJ-1079 1079 - Just another Robbery    PDF (English) Statistics Forum Time Limit: 4 second(s) Memory Limit: 32 MB As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (he wants eve…
题意:给出银行的个数和被抓概率上限.在给出每个银行的钱和抢劫这个银行被抓的概率.求不超过被抓概率上线能抢劫到最多的钱. dp题,转移方程 dp[i][j] = min(dp[i-1][j] , dp[i-1][j-v[i]]) ,dp[i][j]表示前 i 个银行抢劫到 j 这么多钱被抓的概率. 初始化时 dp[0][0] = 0 , 因为 dp[0][1~n]是不可能的情况,dp[0][1~n]=-1. #include<stdio.h> #define maxn 110 #define m…
http://lightoj.com/volume_showproblem.php?problem=1079 Just another Robbery As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (he wants everything quick!) so he decided to rob banks. He wants to make a calculated r…
题意: 从n个数里选出m个来,还要使得这m个数之和被d整除. 给一个n和q,再给n个数,再给q个询问,每个询问包含两个数,d,m; 对于每个case输出每个q个询问的可行的方案数. 思路: 每个数只能被取一次 那我直接dp一下,dp[i][j]直接代表前i个物品有j值: 然后j这个值由2^31*200-这就不行了... 虽然可以/d 变变变!!! 但是我们可以把余数开一维啊,然后还是前i个物品开一维,但是还有选几个再开一维,那就开三维了... 01背包开两维反着更新一下就好了. dp[i][j]…
1079 - Just another Robbery   PDF (English) Statistics Forum Time Limit: 4 second(s) Memory Limit: 32 MB As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (he wants everything quick!) so he decided to rob banks. He…
http://acm.hdu.edu.cn/showproblem.php?pid=2955 如果认为:1-P是背包的容量,n是物品的个数,sum是所有物品的总价值,条件就是装入背包的物品的体积和不能超过背包的容量1-P. 在这个条件下,让装入背包的物品的总价值,也就是bag[i].[v]的和最大 bag.v是每一件物品的价值,bag.p是每件物品的体积 像上面这样想是行不通的.下面有解释 这道题麻烦的是概率这东西没法用个循环表示出来,根据我以往的经验,指望着把给出的测试数据乘上一百或者一万这种…
Robberies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 16565 Accepted Submission(s): 6087 Problem Description The aspiring Roy the Robber has seen a lot of American movies, and knows that the b…