码迷,mamicode.com
首页 >  
搜索关键字:pascals triangle ii    ( 7733个结果
poj1163The Triangle(DP)
题目意思: 给出一个数字三角形,计算从头走到尾的数字之和的最大值。规定只能向下向右下走。 http://poj.org/problem?id=1163 题目分析: 简单DP,动态转化方程:dp[i][j]=max(dp[i+1][j],dp[i+1][j+1])+a[i][j].从下到上进行dp AC代码: #include using namespace std; i...
分类:其他好文   时间:2014-11-08 23:42:45    阅读次数:329
HDU - 4466 Triangle
Description You have a piece of iron wire with length of n unit. Now you decide to cut it into several ordered pieces and fold each piece into a triangle satisfying:  *All triangles are integral....
分类:其他好文   时间:2014-11-08 23:40:43    阅读次数:396
Best Time to Buy and Sell Stock II
这道题目比上一个稍微复杂点,答题思路是要分析价格的走势,找出每一阶段的波谷和波峰,求出每一阶段的利润,然后累加得出总利润。需要预读下一个数字,判断价格的走向,如果之前在下降,现在上升了,则得到了波谷,如果之前上升,现在下降了,则得到了波峰,每次得到波峰就要累加一次利润,特别指出的是,有可能直到末尾之...
分类:其他好文   时间:2014-11-08 22:04:10    阅读次数:208
Leetcode-Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use...
分类:其他好文   时间:2014-11-08 10:26:18    阅读次数:173
Leetcode-Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,...
分类:其他好文   时间:2014-11-08 10:23:23    阅读次数:194
Leetcode-Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo...
分类:其他好文   时间:2014-11-08 09:15:14    阅读次数:187
leetcode Unique Paths II
题目:和上一题类似,就是这个时候给定了矩阵包含0和1,1代表不能从这里走。我的想法其实很明确,还是用动态规划,只是碰到壁垒的时候要进行考虑。还有初始化很重要。因为1本来是要用来代表在这里出发到终点有一种可能的,所以壁垒的1要用其他代替,我用-1代表是壁垒。如果给定的数组第一个数就是1,那永远都出发不...
分类:其他好文   时间:2014-11-08 00:50:30    阅读次数:259
[leetcode]Unique Paths II
问题描述: Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in ...
分类:其他好文   时间:2014-11-07 20:56:34    阅读次数:272
leetcode:Binary Tree Level Order Traversal
该题做法同 Binary Tree Level Order Traversal II,不过是结果没有反转就是了,详细见 http://blog.csdn.net/zzucsliang/article/details/40841527...
分类:其他好文   时间:2014-11-07 20:52:02    阅读次数:139
[ACM] SDUT 2883 Hearthstone II (第二类Stiring数)
Hearthstone II Time Limit: 2000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 The new season has begun, you have n competitions and m well prepared decks during the new season. Each c...
分类:其他好文   时间:2014-11-07 20:49:50    阅读次数:282
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!