码迷,mamicode.com
首页 >  
搜索关键字:maximum sum subarray    ( 25087个结果
UVA 1362 - Exploring Pyramids(计数问题+区间DP)
题目链接:1362 - Exploring Pyramids 白书上的例题,思路是对于每个结点,往后遍历分为左右两边子树来考虑,左边的子树为去掉根节点剩下的子树,而右边是要算上根节点的,这样就不会有重复的情况出现,然后根据乘法原理,左右两边情况相乘为总情况数,然后计算这些总和。  f[i][j]表示[i,j]结点的情况种数,那么 f[i][j] = sum{f[i + 1][k - 1] * ...
分类:其他好文   时间:2014-05-11 07:02:11    阅读次数:277
UVA 11361 - Investigating Div-Sum Property(数位DP)
题目链接:11361 - Investigating Div-Sum Property 白书上的例题,不过没有代码,正好前几天写了一题数位DP的题目,这题也就相对轻松了。 dp[i][x][y]表示加到第i位,数字 % k,数位和 % k的组合情况数,那么现在要添加一个0 - 9的数字上去状态转移为 dp[i + 1][(x * 10 + num) % k][(y + num) % k],计...
分类:其他好文   时间:2014-05-11 05:23:33    阅读次数:316
Leetcode 树 Maximum Depth of Binary Tree
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie Maximum Depth of Binary Tree  Total Accepted: 16605 Total Submissions: 38287 Given a binary tree, find its maximum depth. ...
分类:其他好文   时间:2014-05-11 01:58:31    阅读次数:441
CSU 1424 Qz’s Maximum All One Square
原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1424 逐渐找到做这种题的感觉了。 二分法。g[i][j]存储坐标(i, j)的值,s[i][j]存储的值为左上角为起始点(1,1),右下角为(i, j)的矩形区域内所有值的和,那么...
分类:其他好文   时间:2014-05-10 22:55:11    阅读次数:347
nylg 640 Geometric Sum
Geometric Sum时间限制:1000ms | 内存限制:65535KB难度:3描述Compute (a + a^2 + … + a^n) mod m.(a+a2+…an)mod输入Three integers a,n,m.(1≤a,n,m≤10^18)It ends with EOF.输出T...
分类:其他好文   时间:2014-05-10 05:01:02    阅读次数:339
【LeetCode】Best Time to Buy and Sell Stock II
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:其他好文   时间:2014-05-10 00:24:49    阅读次数:255
Oracle DG 三种模式(转)
DG有下面三种模式– Maximum protection– Maximum availability– Maximum performance 在Maximum protection下, 可以保证从库和主库数据完全一样,做到zero data loss.事务同时在主从两边提交完成,才算事务完成。如...
分类:数据库   时间:2014-05-09 23:19:59    阅读次数:554
Large sum
聪明的办法是想:求前10位,那只要前8位加起来,进2位就OK。本的办法,就是真的加起来,截前面10位。如我。numList = str.split()sum = 0for i in range(0,len(numList)): sum += int(numList[i][0:50]) p...
分类:其他好文   时间:2014-05-09 23:16:32    阅读次数:350
USACO/fence8 迭代加深搜索+剪枝
题目链接 迭代加深搜索思想。 枚举答案K,考虑到能否切出K个木头,那么我们当然选最小的K个来切。 1、对于原材料,我们是首选最大的还是最小的?显然,首选大的能够更容易切出,也更容易得到答案。 2、对于目标木头,我们是优先得到最大的还是最小的?显然,由于K个木头我们都要得到,那么当然先把最大的(最难得到的)先得到,这种搜索策略更优。 3、假设总原材料为all,前K个木头总和为sum,那...
分类:其他好文   时间:2014-05-09 21:07:28    阅读次数:305
Leetcode | Path Sum I && II
Path Sum IGiven 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 gi...
分类:其他好文   时间:2014-05-09 13:21:59    阅读次数:320
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!