题意:
给出一颗有根树,边权均为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
House Robber II问题:Note:This is an extension ofHouse Robber.After robbing those houses on that street, the thief has found himself a new place for his ...
分类:
其他好文 时间:
2015-05-28 00:42:45
阅读次数:
158
IYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping y...
分类:
其他好文 时间:
2015-05-27 06:17:38
阅读次数:
105
创业完全不能依靠直觉,生活则相反要相信直觉。出色的创业者,并非擅长于创业。作为一个创业新手,成功来源于充分理解用户。怎么筹集天使轮?不仅没有必要仔细学习创业方法论,学它甚至可能很危险。按照创业步骤,按部就班,playing house,寻找通关游戏的小把式。对于创业这个游戏,有什么外挂的方法,有什么...
分类:
其他好文 时间:
2015-05-24 23:29:47
阅读次数:
153
House Robber II
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...
分类:
其他好文 时间:
2015-05-23 00:07:43
阅读次数:
136