
动态规划
他说少年如歌
现在不常看博客,有问题可通过qq联系,937035773.
展开
-
动态规划之最长公共子序列
最长公共子序列,这道题难度比较高,不建议初学者看,最好是有一定的基础。原创 2015-04-17 16:58:46 · 382 阅读 · 0 评论 -
hdu 1677 Nested Dolls LIS + 动态规划
Problem DescriptionDilworth is the world’s most prominent collector of Russian nested dolls: he literally has thousands of them! You know, the wooden hollow dolls of different sizes of which the sma转载 2017-04-14 16:11:01 · 464 阅读 · 0 评论 -
hdu 2391 Filthy Rich
Problem DescriptionThey say that in Phrygia, the streets are paved with gold. You’re currently on vacation in Phrygia, and to your astonishment you discover that this is to be taken literally: small原创 2017-04-05 09:28:13 · 244 阅读 · 0 评论 -
HDU 1171 母函数或者01背包变形
Big Event in HDUTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 34449 Accepted Submission(s): 11946Problem DescriptionNowada原创 2016-05-23 10:28:38 · 310 阅读 · 0 评论 -
hdu1059 多重背包
题意就是给你价值从1到6的物体的个数求是否可以给他们平分用多重背包解决AC代码:#include #include #include #include using namespace std;int dp[120005];int w[120005],a[1000],b[1000];int max(int x,int y){ return x>y?x:y原创 2016-04-24 21:06:55 · 483 阅读 · 0 评论 -
HDU1160 FatMouse's Speed
点击打开题目链接原创 2016-04-20 12:29:44 · 222 阅读 · 0 评论 -
hdu1114 Piggy-Bank
其实就是用完全背包罢了 但是我却因为数组开小了 超时了好几次 发现之后顿时感觉快崩溃了AC:#include #include #include #include #define INF 0x3f3f3f3fusing namespace std;int dp[100001];int t, p[500005], w[100005];int min(原创 2016-04-19 20:50:29 · 249 阅读 · 0 评论 -
hdu 1421 搬寝室
搬寝室Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23857 Accepted Submission(s): 8153Problem Description搬寝室是很累的,xhd深有体会.时间追述2原创 2016-04-18 10:25:38 · 205 阅读 · 0 评论 -
hdu2571 命运
简单的模拟即可。AC代码:#include #include #include #define INF -0x3f3f3f3fusing namespace std;int dp[1005][1005],map[1005][1005];int max(int x,int y){ return x > y?x:y;}int main(){原创 2016-04-13 20:43:54 · 216 阅读 · 0 评论 -
最大连续子序列和 HDU 1231 (时间复杂度为O(n))
最大连续子序列和最简单的想法就是枚举 但是一个一个枚举 时间有点长 下面介绍三种不同时间复杂度的算法1 O(n^3)for(int i = 0; i { for(int j = j; j { sum = 0; for(int k = i; k { sum+=map[k]原创 2016-04-13 20:00:06 · 373 阅读 · 0 评论 -
动态规划之01背包
给你n个物品,还有一个容量为v的容器,随后在给你n个物品的重量c和价值wF[i][j]表示把前i个物品放在容量为j的背包的最大价值然后根据第i件物品是否要放来决策 F[i-1][j]表示前i-1个物品放在容量为j的背包中的最大价值F[i-1][j-C[i]]+W[i]表示若是要放第i件物品 那么前i-1个物品所要用的背包容量为j-C[i]然后取两者的最大值即可原创 2016-04-13 16:35:47 · 278 阅读 · 0 评论 -
nyoj 203 三国志
三国志时间限制:3000 ms | 内存限制:65535 KB难度:5描述 《三国志》是一款很经典的经营策略类游戏。我们的小白同学是这款游戏的忠实玩家。现在他把游戏简化一下,地图上只有他一方势力,现在他只有一个城池,而他周边有一些无人占的空城,但是这些空城中有很多不同数量的同种财宝。我们的小白同学虎视眈眈的看着这些城池中的财宝。按照游戏的规则,他只要指派一名原创 2017-05-05 11:20:04 · 476 阅读 · 0 评论