题目
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [?2,1,?3,4,?1,2,1,?5,4],
the contiguous subarray [4,...
分类:
其他好文 时间:
2014-06-19 12:08:20
阅读次数:
270
http://poj.org/problem?id=3233
ps转:
用二分方法求等比数列前n项和:即
原理:
(1)若n==0
(2)若n%2==0
(3)若n%2==1
代码如下:
LL sum(LL p,LL n)
{
if(n==0) return 1;
i...
分类:
其他好文 时间:
2014-06-15 20:01:44
阅读次数:
210
题目
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums
to T.
The same repeated number may be chosen from C un...
分类:
其他好文 时间:
2014-06-15 20:00:18
阅读次数:
185
Given a binary tree and a sum, find all root-to-leaf paths where each path's
sum equals the given sum.
For example:
Given the below binary tree and
sum = 22,
5
...
分类:
其他好文 时间:
2014-06-15 19:55:39
阅读次数:
191
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 binary tree and sum
...
分类:
其他好文 时间:
2014-06-15 19:26:23
阅读次数:
207
题目
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers
sums to T.
Each number in C may only be used once in...
分类:
其他好文 时间:
2014-06-15 19:24:21
阅读次数:
229
Given a non-negative number represented as an array of digits, plus one to the number.
The digits are stored such that the most significant digit is at the head of the list.
思路:原有数组需要多出一位的唯一条件是数组所...
分类:
其他好文 时间:
2014-06-15 18:42:43
阅读次数:
162
题意:给n个数,为有多少互质对;
解法:然后求出mou值,然后求出1,2,3...max的倍数的个数,每个出现在gcd中的对数(num[i]*(num[i]-1))/2,乘上mou值进行容斥计算。
代码:/******************************************************
* author:xiefubao
******************...
分类:
其他好文 时间:
2014-06-15 16:16:11
阅读次数:
274
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 bin...
分类:
其他好文 时间:
2014-06-15 09:34:35
阅读次数:
226
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down or right at...
分类:
其他好文 时间:
2014-06-13 20:36:56
阅读次数:
280