HDU 1147 Pick-up sticks】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意:给你一根长为m的长木板和一些小木棒,每一根小木棒有它的长度和价值,这些小木棒要放在长木板上并且每一根小木棒的重心要在长木板上(即可以露出一半的长),问最大价值是多少. dp[i][j][k]  表示前i个小棒放到长度为j的木板上,其中有k个小棒放在边沿部分, 边沿部分的小棒需要尽量放在木板外面(贪心思维),所以放在边沿的木棒落在木板上的长度为l/2.然后就是简单的01背包问题了. tip…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意: 给你N个金条和一张长度为L的桌子.每个金条长度为a[i],价值为w[i].金条只能在桌子上横着摆一排,并且只要金条的重心(中心)在桌子上,就可以放.问你在桌子上能够摆的金条的最大总价值. 题解: 首先表示状态: 考虑到第i个金条,在这之前已经占用了j的长度,在k个端点摆了金条.即:dp[i][j][k] 如何转移(逆推): 对于第i个金条,有三种决策:摆在桌子中央.摆在桌子端点处.不摆…
背包变形.与普通的背包问题不同的是:允许有两个物品可以花费减半. 因此加一维即可,dp[i][j][k]表示前i个物品,有j个花费减半了,总花费为k的情况下的最优解. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include&l…
Pick The Sticks Time Limit: 15000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 593    Accepted Submission(s): 193 Problem Description The story happened long long ago. One day, Cao Cao made a special order c…
D - Pick The Sticks Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description The story happened long long ago. One day, Cao Cao made a special order called "Chicken Rib" to his army. No one got his point and all became very panic. However, Cao…
Pick The Sticks Time Limit: 15000/10000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) The story happened long long ago. One day, Cao Cao made a special order called "Chicken Rib" to his army. No one got his point and all became v…
D - Pick The Sticks Description The story happened long long ago. One day, Cao Cao made a special order called "Chicken Rib" to his army. No one got his point and all became very panic. However, Cao Cao himself felt very proud of his interesting…
题解:每放一根棍子,都判断一下它与它前面的且在顶端的棍子是否相交,相交的话则将相应的棍子从解空间中除去. #include <cstdio> const double eps=1e-14; const int maxn=1e5+10; struct node{double x1,y1,x2,y2;int w;}e[maxn],f[maxn]; double cross(double x1,double y1,double x2,double y2){return x1*y2-x2*y1;} i…
Pick-up sticks Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1872    Accepted Submission(s): 706 Problem Description Stan has n sticks of various length. He throws them one at a time on the fl…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意:往长为L的线段上覆盖线段,要求:要么这些线段都在L的线段上,要么有不超过自身长度一半的部分在线段外面,最多有两条这样的线段(在两头). dp(i,j,k)表示前i个线段覆盖在长度为j的线段上,期中有k个线段不完全在这个线段上的最大价值.考虑线段长度的奇偶问题,所以事先把L和其他线段长度乘2,以便操作.所以枚举所有线段,一般情况,就是01背包的问题,dp(i,j,k)=max(dp(i,j…