随笔分类 -  算法--数据结构

摘要:关于分治算法在树上的应用详情请查看09年QZC国家集训队论文。题目大意: 树含N个点,点之间有权值,求两点间权值和小于等于K的点对数量( N <= 10000 )解题思路:对于以rt为根节点的树,其树上两点间一条路径只有两种情况,分别为过根节点,不过根节点。 这样,启发了我们使用分治的思想来解决此题。 若不过根节点,则通过递归处理,其实也可理解为过根节点,但过了根的那部分为0.可简化代码 若过根节点, 则 dist(i)+dist(j) <= K 且 father(i) != father(j) 其中哦功能 dist(i) 为 子树上节点到根节点rt的距离, fath... 阅读全文
posted @ 2012-12-17 13:35 yefeng1627 阅读(269) 评论(0) 推荐(0)
摘要:B. Jury Sizetime limit per test1 secondmemory limit per test256 megabytesinputinput.txtoutputoutput.txtIn 2013, the writers of Berland State University should prepare problems fornOlympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 ton. For each Olympiad we kno 阅读全文
posted @ 2012-12-09 20:25 yefeng1627 阅读(290) 评论(0) 推荐(0)
摘要:B. Physics Practicaltime limit per test1 secondmemory limit per test256 megabytesOne day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did as much asnmeasurements, and recorded the results in the notebook. After that he w 阅读全文
posted @ 2012-12-08 20:17 yefeng1627 阅读(273) 评论(0) 推荐(0)

Launch CodeCogs Equation Editor