1.accumulate的用法:int sum = accumulate(ivec.begin(), ivec.end(), 0 );第三个参数时累加的初值,更重要的是accumulate对要累加元素的类型一无所知,所以容器内的类型要与第三个实参的类型匹配,或者可转换成第三个实参的类型。2.find...
分类:
其他好文 时间:
2014-06-15 22:42:19
阅读次数:
285
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, 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 binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
此题和求二叉树的最短路径几乎一模一样。
public int...
分类:
其他好文 时间:
2014-06-15 16:36:40
阅读次数:
209
Question: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, .....
分类:
其他好文 时间:
2014-06-14 20:59:07
阅读次数:
188
Decription: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, gi...
分类:
其他好文 时间:
2014-06-14 19:46:12
阅读次数:
251
题目:
链接:点击打开链接
题意:
输入n个点,要求选m个点满足连接m个点的m-1条边权值和sum与点的权值和ans最小,即sum/ans最小,并输出所选的m个点,如果有多种情况就选第一个点最小的,如果第一个点也相同就选第二个点最小的........
求一个图中的一颗子树,使得Sum(edge weight)/Sum(point weight)最小~
数据...
分类:
其他好文 时间:
2014-06-14 07:05:34
阅读次数:
350
真的被这道题目恶心到了。。。281行代码。。。比一个模拟题还费事。。。
为了方便起见,在数列的前面和后面都加一个0点。
add x :把第k2+2个点旋转至root1.然后sum[root10]+=x;
reverse:把第k1+2个点旋转至root1.然后rev[root10]^=1;
insert x:得到第2个点,然后在第2个点之后插入x。
delete
:把第1个点旋...
分类:
其他好文 时间:
2014-06-14 00:54:26
阅读次数:
324