码迷,mamicode.com
首页 >  
搜索关键字:max sum plus plus    ( 46271个结果
字典树-百度之星-Xor Sum
分析:暴力要超时,所以把每个数字转换为长度为32的0-1字符串,用字典树。因为其公共前缀的特性,空间上可以承受。因为是二叉树,用node[SIZE][2]存放。不知道new速度是否会慢很多,所以没用指针。...
分类:其他好文   时间:2014-05-18 18:37:37    阅读次数:218
hdu1257
首先求最多能拦截多少颗导弹,则是求一个最长下降子序列的问题。。则找到动态转移方程。。 dp[i]=max(dp[j])+1,ja[i],因为dp[j]所表示的就是一个有序下降子序列。。。所以加进来也将是一个有序上升数列。。 然后是最少需要多少套导弹系统。。。有点贪心的做法。。就是要拦截导弹,尽量用小的去拦截可以拦截的导弹。。最后得到的导弹系统套数是最少的。。 题目链接: http://...
分类:其他好文   时间:2014-05-18 18:31:47    阅读次数:210
求树的最大路径和
求树的最大路径和(Binary Tree Maximum Path Sum)...
分类:其他好文   时间:2014-05-18 18:25:41    阅读次数:235
已知二叉树的先序遍历序列和中序遍历序列,输出该二叉树的后序遍历序列
题目描述 输入二叉树的先序遍历序列和中序遍历序列,输出该二叉树的后序遍历序列。 输入 第一行输入二叉树的先序遍历序列; 第二行输入二叉树的中序遍历序列。 输出 输出该二叉树的后序遍历序列。 示例输入 ABDCEF BDAECF 示例输出 DBEFCA#include #include #define MAX 50+3 using namespace std; typede...
分类:其他好文   时间:2014-05-18 15:59:41    阅读次数:185
简易版的堆的写法
个人认为重点写出max_heapify和parent_heapify两个函数即可,这个版本内存管理的功能显得特别简单: #include #include using namespace std; class Heap { public: int size, capacity; int *ele; void max_heapify(int i,int heap[],int len...
分类:其他好文   时间:2014-05-18 15:15:29    阅读次数:220
[LeetCode]4Sum
4Sum Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target....
分类:其他好文   时间:2014-05-18 13:49:09    阅读次数:306
poj 1952 BUY LOW, BUY LOWER 最长下降子序列+统计不重复方案数
dp[i]=max(dp[i],dp[j]+1) ja[i] dp[i]表示长度为i的最长下降子序列的长度。 r[i]表示长度为i的最长下降子序列的方案数。 考虑这样一个问题,比如6 3 9 3,对于两个3,他们数字一样并且dp值也一样,那么r[2]的方案数是没有意义的 因为能通过第一个3扩展的也能通过第二个3扩展,所以直接把r[2]=0。 对于一次扩展若dp[j]+1==dp[i],则...
分类:其他好文   时间:2014-05-18 06:31:43    阅读次数:249
2014百度之星第三题Xor Sum
Xor Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others) Total Submission(s): 4445    Accepted Submission(s): 652 Problem Description Zeus 和 Prometheus 做了一个游戏,...
分类:其他好文   时间:2014-05-18 05:21:59    阅读次数:277
leetcode -day17 Path Sum I II & Flatten Binary Tree to Linked List & Minimum Depth of Binary Tree
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
hdu 2159 FATE
题目:     链接:点击打开链接 算法:     二维的完全背包; 思路:     状态转移方程: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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!