Problem DescriptionYou are building a house. You’d prefer if all the walls have a precise right angle relative to the ground, but you have no device t...
分类:
其他好文 时间:
2015-06-06 19:36:02
阅读次数:
111
Description
There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.
...
分类:
移动开发 时间:
2015-06-06 15:02:30
阅读次数:
157
POJ 2057 The Lost House 树形DP+贪心...
分类:
其他好文 时间:
2015-06-04 13:47:48
阅读次数:
104
This problem is a little tricky at first glance. However, if you have finished the "House Robber" problem, this problem can simply bedecomposed into t...
分类:
其他好文 时间:
2015-06-03 00:42:11
阅读次数:
231
题意:
给出一颗有根树,边权均为1;
一个S在根结点上,要找到在某个叶子结点上的它的房子;
有的结点上有w,可以告诉S当前结点的子树上是否有它的房子;
房子在每个叶子结点的概率相等,选择一种最佳的计划,来让S走的期望值最小;...
分类:
其他好文 时间:
2015-06-02 09:30:52
阅读次数:
115
Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all...
分类:
其他好文 时间:
2015-05-30 21:15:01
阅读次数:
152
可以复用house robber的代码,两趟dp作为两种情况考虑,选最大值#include #define MAX 1000#define max(a,b) ( (a)>(b)?(a):(b) )int dp[MAX]={0};int rob1(int* a, int n) { int i; ...
分类:
其他好文 时间:
2015-05-30 19:47:09
阅读次数:
112
动态规划,构造dp[n][2]数组,
dp[i][0]: 在不取nums[i]的情况下,从nums[0, 1, ..., n]中能获得的最大值;
dp[i][1]: 在取nums[i]的情况下,从nums[0], 1, ..., n]中能获得的最大值。
注意到,max(dp[i][0], dp[i][1])表征了从nums[0, 1, ..., n]中获得的最大值。
初始化:
dp[0][0] = 0;
dp[0][1] = nums[1].
状态方程:
dp[i][0] = max(dp[i-1][0...
分类:
其他好文 时间:
2015-05-30 16:43:39
阅读次数:
108
简单的动态规划状态方程:dp[i]=max{dp[i-1],dp[i-2]+a[i]}.//其实就是分为选择a[i]和不选择a[i]两种情况,取最大值。代码如下:#define MAX 1000#define max(a,b) ( (a)>(b)?(a):(b) )int dp[MAX]={0};i...
分类:
其他好文 时间:
2015-05-30 16:28:26
阅读次数:
92
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo...
分类:
其他好文 时间:
2015-05-30 01:48:23
阅读次数:
101