码迷,mamicode.com
首页 >  
搜索关键字:max sum plus plus    ( 46271个结果
[LeetCode] Binary Tree Maximum Path Sum(递归)
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example: Given the below binary tree, 1 ...
分类:其他好文   时间:2014-07-30 20:33:34    阅读次数:193
HDU 1080 Human Gene Functions
最长公共子序列的变形题目大意:给出两个基因序列,求这两个序列的最大相似度。题目中的表格给出了两两脱氧核苷酸的相似度。状态转移方程为:dp[i][j] = max(dp[i-1][j]+Similarity(s1[i], '-'), dp[i][j-1]+Similarity(s2[...
分类:其他好文   时间:2014-07-30 20:33:04    阅读次数:176
codeforces159D - Palindrome pairs 二重DP
题意:给你一个字符串,问你其中不重叠的回文字串对有多少解题思路:这题用到两种方法,不过其实是一个很巧妙的二重dp1)暴力求解以i开头,j结尾的是否为回文,如果是,ans += sum[i-1](ans 为答案, sum[i]为在 1 - i内回文串的个数--需要dp求解)这里非常耗时,时间大约为 n...
分类:其他好文   时间:2014-07-30 20:05:44    阅读次数:276
POJ 2029 DP || 暴力
在大矩形中找一个小矩形 使小矩形包含的*最多 暴力或者DP  水题 暴力: #include "stdio.h" #include "string.h" int main() { int n,m,w,i,s,t,j,k,l,ans,sum,x,y; int map[101][101]; while (scanf("%d",&w)!=EOF) ...
分类:其他好文   时间:2014-07-30 17:44:24    阅读次数:201
A + B Problem II(杭电1002)
/*A + B Problem II Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.   Input The first line of the input contains an...
分类:其他好文   时间:2014-07-30 17:38:54    阅读次数:306
hdu4893 Wow! Such Sequence!
线段树结点上保存一个一般的sum值,再同时保存一个fbsum,表示这个结点表示的一段数字若为斐波那契数时的和 当进行3操作时,只用将sum = fbsum即可 其他操作照常进行,只是单点更新的时候也要先向下更新 #include #include #include #include #include #include #include #include #includ...
分类:其他好文   时间:2014-07-30 17:33:24    阅读次数:153
HDU2159 二维费用背包
题目链接:FATE 状态转移方程: dp[ren][num] =max(dp[ren-耐久值][num-1]+ 经验值,dp[ren][num]) dp表示:当前忍耐度ren下杀敌数为num的经验值 枚举分别枚举 所有怪物种类、耐久度、杀怪数 最后在从小到达枚举消耗的耐久度即可 #include #include #include #include #inclu...
分类:其他好文   时间:2014-07-30 17:27:34    阅读次数:176
HDU1864 最大报销额 01背包
很裸的01背包,水题,注意控制精度 #include #include #include #include #include const int INF = 1e6; using namespace std; int dp[4*INF],cost[5],w[31]; int max(int x,int y) { if(x > y) return x; ...
分类:其他好文   时间:2014-07-30 17:26:44    阅读次数:216
c语言实现hashtable,类似C++的map和iOS的NSDictionary
跟线性数组和链表不同,HashTable是快速查找的数据结构。本文中的HashTable使用链表处理数组。 该HashTable可以指定table的长度,提供了遍历的方法。包括table的长度的选择也比较讲究。 cp_int32 nPrime[MAX_HASH_PRIME_ARRAY_NUM] = { 17, 37, 79, 163, 331, 673, 1361 }; 就是说table的长度来取自上面这个数组。比如用户设定了200,那么ta...
分类:移动开发   时间:2014-07-30 17:26:14    阅读次数:380
POJ 2948 DP
一个row*col的矩阵,每个格子内有两种矿yeyenum和bloggium,并且知道它们在每个格子内的数量是多少。最北边有bloggium的收集站,最西边有 yeyenum 的收集站。现在要在这些格子上面安装向北或者向西的传送带(每个格子自能装一种)。问最多能采到多少矿。 DP,状态转移方程为 dp[i][j]=Max(dp[i][j-1]+suma[i][j],dp[i-1][...
分类:其他好文   时间:2014-07-30 17:25:54    阅读次数:263
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!