hdu 5115(2014北京—dp)】的更多相关文章

题意: 有一排狼,每只狼有一个伤害A,还有一个伤害B.杀死一只狼的时候,会受到这只狼的伤害A和这只狼两边的狼的伤害B的和.如果某位置的狼被杀,那么杀它左边的狼时就会收到来自右边狼的B,因为这两只狼是相邻的了.求杀掉一排狼的最小代价. 思路:感觉自己在动规上真的是啥都不会- -!,完全看不出来. dp[i][j]表示i-j的最小情况. 再用k表示最后攻击的那一个所以公式 dp[i][j]=min(dp[i][k-1]+dp[k+1][j]+a[k]+b[i-1]+b[j+1],dp[i][j]);…
题意: 从n个数中任选一些数,问有多少种选法使他们异或和不小于M 思路: dp[i][j]表示选i个数异或和为j,则方程dp[i][j] = dp[i-1][j](不选i)+ dp[i-1][j^a[i]] #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; const…
Dire Wolf Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 3815    Accepted Submission(s): 2266 Problem Description Dire wolves, also known as Dark wolves, are extraordinarily large and powerfu…
题意: 随机选择一个数,如果后面有比他小的就进行交换,直到没有为止(算一轮).求多少轮后为递增序列 思路: 倒着找,如果有比经过的最小数大的,ans+1 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; int a[1000005]; int main() { int T,n; scanf("%d&qu…
给出某个时刻对应的速度 求出相邻时刻的平均速度 输出最大值 Sample Input23 // n2 2 //t v1 13 430 31 52 0 Sample OutputCase #1: 2.00Case #2: 5.00 # include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <string> # include…
题目链接:  HDU 1011 树形背包(DP) Starship Troopers 题意:  地图中有一些房间, 每个房间有一定的bugs和得到brains的可能性值, 一个人带领m支军队从入口(房间1)进入, 只有到达某个房间并且将bugs全部杀死, 才能得到相应该的值. 问最多能获得多少可能性值. PS  1). 一支军队能杀死 20 bugs,  当一支军队发生战争之后就不能再到其它地方去了 2) . 不能走回头路 分析:  [树形背包] 用dp[i][j]表示到达房间 i 的军队数为…
Ring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3180    Accepted Submission(s): 1033 Problem Description For the hope of a forever love, Steven is planning to send a ring to Jane with a rom…
一看就是状压,由于是类似博弈的游戏.游戏里的两人都是绝对聪明,那么先手的选择是能够确定最终局面的. 实际上是枚举最终局面情况,0代表是被Bob拿走的,1为Alice拿走的,当时Alice拿走且满足变换成魔法石,那么相当于是Alice完成了该次操作,增加上次状态值,否则相当于先后手交换,该状态下减去上个状态值. /** @Date : 2017-09-12 23:51:53 * @FileName: HDU 4778 状压DP 或 记忆化 好题.cpp * @Platform: Windows *…
HDOJ(HDU).3466 Dividing coins ( DP 01背包 无后效性的理解) 题意分析 要先排序,在做01背包,否则不满足无后效性,为什么呢? 等我理解了再补上. 代码总览 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nmax 505 #define nn 505*100 using namespace std;…
HDOJ(HDU).2546 饭卡(DP 01背包) 题意分析 首先要对钱数小于5的时候特别处理,直接输出0.若钱数大于5,所有菜按价格排序,背包容量为钱数-5,对除去价格最贵的所有菜做01背包.因为这时候还剩下5块钱,直接买最贵的那个菜,就可以保证剩下来的钱数是最小的. 代码总览 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nma…