Prime Distance
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 12811
Accepted: 3420
Description
The branch of mathematics called number theory is about p...
分类:
其他好文 时间:
2014-11-12 13:51:21
阅读次数:
248
In geometry the Fermat point of a triangle, also called Torricelli point, is a point such that the total distance from the three vertices of the trian...
分类:
其他好文 时间:
2014-11-10 21:14:40
阅读次数:
269
题意:给你n-1条边,然后没两个节点的距离按照递增的顺序,求出前k项的和。官方题解:把所有边(u,v) 以及(v,u)放入一个队列,队列每弹出一个元素(u,v),对于所有与u相邻的点w,如果w!=v,就把(w,u)入队。这样就能一个一个生成前K小的距离。 注意到每条边实际上会入队两次,只要把K翻倍且...
分类:
其他好文 时间:
2014-11-10 19:31:48
阅读次数:
156
The K-th Distance
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 332 Accepted Submission(s): 90
Problem Description
Given a tre...
分类:
其他好文 时间:
2014-11-10 10:03:41
阅读次数:
196
Given a binary tree, a target node in the binary tree, and an integer value k, print all the nodes that are at distance k from the given target node. ...
分类:
其他好文 时间:
2014-11-09 23:30:26
阅读次数:
235
题意:输入一棵树,输出前k小的点对最短距离dis(i,j)的和。模拟,官方题解说得很清楚了。不重复了。http://bestcoder.hdu.edu.cn/需要注意的是,复杂度要O(n+k),不能用set,map之类的标记是否访问。一开始TLE了,去掉标记后wa了。最后发现对队列的元素加个前缀,就...
分类:
其他好文 时间:
2014-11-09 19:27:27
阅读次数:
278
题意:N个点的一棵树。定义点u和点v的距离等于它们之间的路径(唯一的)的长度。这样我们可以得到n*(n-1)/2个距离。将它们从小到大排序,问前K个数的和是多少。思路:将边长为1的树枝都入队列。每次取出一个,然后从这根树枝的前端生出一个新点,变成距离加1的一根新树枝,将其入队列。如此操作下去。可得到...
分类:
其他好文 时间:
2014-11-09 15:07:22
阅读次数:
186
The K-th Distance
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 202 Accepted Submission(s): 50
Problem Description
Given a tree, w...
分类:
其他好文 时间:
2014-11-09 13:59:19
阅读次数:
376
Given a string and a positive integer d. Some characters may be repeated in the given string. Rearrange characters of the given string such that the s...
分类:
其他好文 时间:
2014-11-08 16:27:57
阅读次数:
186
Distance Statistics
Time Limit: 2000MS
Memory Limit: 64000K
Total Submissions: 1667
Accepted: 532
Case Time Limit: 1000MS
Description
Frustrated at the number of d...
分类:
其他好文 时间:
2014-11-05 13:10:43
阅读次数:
217