Problem Definition: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 yo...
分类:
其他好文 时间:
2015-07-21 22:11:28
阅读次数:
121
递归思路 超时算法#includeusing namespace std;#define Size 101int Triangle[Size][Size];int n;int GetAns( int i, int j ){ if( i==n ) return Tr...
分类:
其他好文 时间:
2015-07-21 21:57:50
阅读次数:
118
Problem Definition:Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return[ [1], [1,1], [1,2,1]...
分类:
其他好文 时间:
2015-07-21 21:47:31
阅读次数:
93
GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]...
分类:
其他好文 时间:
2015-07-21 20:24:39
阅读次数:
100
题目链接:http://poj.org/problem?id=1163
其实这个题目有很多解法,但是我们可以看下这个用一位数组的高效动规解法,这个我上课时老师讲的,很不错;
先保存最后一行4 5 2 6 5,然后更新最大值7=max(4,5)+2;依次类推,很显然,我们就可以得到状态转移方程:dp[j]=max(dp[j],dp[j+1])+a[i][j];
这样这个题目就很好解决了;
...
分类:
其他好文 时间:
2015-07-21 17:12:55
阅读次数:
104
Time Limit: 2 Seconds
Memory Limit: 65536 KB
Mathematics can be so easy when you have a computer. Consider the following example. You probably know that in a right-angled triangle, the le...
分类:
其他好文 时间:
2015-07-21 12:50:20
阅读次数:
125
通道:http://poj.org/problem?id=2079题意:n个点选面积最大的三角形代码: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int MAX_N = 100...
分类:
其他好文 时间:
2015-07-20 15:51:20
阅读次数:
126
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
Find th...
分类:
其他好文 时间:
2015-07-16 09:52:17
阅读次数:
155
题目:By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
Find...
分类:
其他好文 时间:
2015-07-16 09:47:47
阅读次数:
157
hdu 3304 Interesting Yang Yui Triangle
题意:
给出P,N,问第N行的斐波那契数模P不等于0的有多少个?
限制:
P
思路:
lucas定理,
如果:
n = a[k]*p^k + a[k-1]*p^(k-1) + ... + a[1]*p + a[0]
m = b[k]*p^k + b[k-1]*p^(k-1) + ... +...
分类:
其他好文 时间:
2015-07-15 21:06:56
阅读次数:
266