求树的最大路径和(Binary Tree Maximum Path Sum)...
分类:
其他好文 时间:
2014-05-18 18:25:41
阅读次数:
235
http://acm.hdu.edu.cn/showproblem.php?pid=3790
有两个条件:距离和花费。首先要求距离最短,距离相等的条件下花费最小。
dijkstra,只是在判断条件时多考虑了花费。
注意重边。
#include
#include
#include
#include
#include
#include
#include
#incl...
分类:
其他好文 时间:
2014-05-18 15:14:22
阅读次数:
235
给你一个n*n的格子的棋盘,每个格子里面有一个非负数。
从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大。...
分类:
其他好文 时间:
2014-05-18 13:35:56
阅读次数:
287
题目:
链接:点击打开链接
思路:
搜索入门题。
代码:
#include
#include
#include
using namespace std;
int m,n;
char s[110][110];
int vis[110][110];
void dfs(int x,int y)
{
if(s[x][y] == '*' || vis[x][y])
...
分类:
其他好文 时间:
2014-05-18 10:46:12
阅读次数:
277
【题目】
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, only n...
分类:
其他好文 时间:
2014-05-18 10:22:34
阅读次数:
367
题目:
链接:点击打开链接
题意:
武汉大学有很多漂亮的妹纸,,,,,,,他们有一块待剪的布,他们想把它剪成很多小块做围巾,每个人喜欢不同的风格,他们把每一块的价值写在了纸上,现在有一个机器,可以把一块布剪成两块矩形的布,要求你用这台机器把原始的大布剪成纸上出现的小布,他们希望的到小块布的价值最大,当然不要求用完所有的布。。
思路:
首先它是一个背包问题:1>大布...
分类:
其他好文 时间:
2014-05-18 09:30:17
阅读次数:
267
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=3376
http://acm.hdu.edu.cn/showproblem.php?pid=2686
http://poj.org/problem?id=3422
POJ 3422为从矩阵左上角走到右下角,最多走k次,每个格子里的数字只能算一次,后面可以重复经过,求经过的各个数字的和的最大...
分类:
其他好文 时间:
2014-05-18 05:30:06
阅读次数:
358
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4648
Magic Pen 6
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1857 Accepted Submiss...
分类:
其他好文 时间:
2014-05-18 04:56:14
阅读次数:
317
1、
??
Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below...
分类:
其他好文 时间:
2014-05-18 03:25:06
阅读次数:
301
题目:
链接:点击打开链接
算法:
二维的完全背包;
思路:
状态转移方程:dp[j][m] = max(dp[j][m],dp[j-b[i]][m-1]+a[i]);表示用j的忍耐度杀死m个怪兽能够得到的最大的经验值。
代码:
#include
#include
#include
using namespace std;
int dp[110][110];...
分类:
其他好文 时间:
2014-05-18 03:05:42
阅读次数:
338