
DP
Script-Boy
这个作者很懒,什么都没留下…
展开
-
zoj 1095 Humble Numbers
丑数,好像在面试宝典上见过,不错的动态规划题 状态转移方程 :hum[i]=min(min(2*hum[index[0]],3*hum[index[1]]),min(5*hum[index[2]],7*hum[index[3]])); 因为此题的当前状态跟转移状态不具有直接联系,而是顺序由前面四个状态的移动来决定 #include #include #define MAX 5843 us原创 2013-08-26 19:34:58 · 495 阅读 · 0 评论 -
zoj 1093 Monkey and Banana
DP 第一次做竟然连题目都没看懂,最后看了别人的代码,最长不下降子序列一点也不熟练。 砖头无穷多但每个类型的长方体有三种变换方法。 先求出三种变换形态,按长宽大小排序。最后求最长不下降子序列 #include #include #define MAX 30 using namespace std; typedef struct { int a,b,h; }Block;原创 2013-10-27 17:54:30 · 483 阅读 · 0 评论 -
leetcode 动态规划练习
279. Perfect Squares 给定正整数n,找到最少可分解为几个数的平方和为n。 例如 n = 12 return 3 因为12 = 4+4+4 。给定n = 13 返回 2 因为13 = 4+ 9 class Solution { public: int numSquares(int n) { int *a = new int[n+1];原创 2017-06-30 11:11:20 · 245 阅读 · 0 评论