【题意】 给出一棵树和多组查询,求以每个节点为LCA的查询数有多少? 【错误点】 ①读入的时候,注意它的空格是随意的呀!一开始不知道怎么弄,后来看了DISCUSS区大神的话: 询问部分输入:scanf("%d",&m);for(int i=0;i<m;i++){scanf(" (%d %d)",&a ...
分类:
其他好文 时间:
2016-08-12 18:16:28
阅读次数:
101
题目链接:http://poj.org/problem?id=1470 题意是给出一颗树,q个查询,每个查询都是求出u和v的LCA; 以下是寻找LCA的预处理过程: 详细解释 图文详解 本题可以使用预处理的方式,也可以使用离线处理,由于不需要求任意两数之间的LCA所以可以使用离线算法; #inclu ...
分类:
编程语言 时间:
2016-08-06 19:03:46
阅读次数:
417
使用js或者jquery查找父元素、子元素经常遇到。可是用起来总容易混淆,这里统一总结了一下,以后用起来相信会方便好多 这里jquery向上查找父元素 用到的方法:closest() parents() parent() 向下查找子元素 用到的方法:find() children() js用的是 c ...
分类:
Web程序 时间:
2016-08-06 12:39:33
阅读次数:
153
Given a target number, a non-negative integer k and an integer array A sorted in ascending order, find the k closest numbers to target in A, sorted in ...
分类:
其他好文 时间:
2016-07-31 11:42:59
阅读次数:
116
16. 3Sum Closest Total Accepted: 86565 Total Submissions: 291260 Difficulty: Medium Given an array S of n integers, find three integers in S such that ...
分类:
其他好文 时间:
2016-07-29 22:43:57
阅读次数:
197
jQuery 遍历函数包括了用于筛选、查找和串联元素的方法。 函数 描述 .add() 将元素添加到匹配元素的集合中。 .andSelf() 把堆栈中之前的元素集添加到当前集合中。 .children() 获得匹配元素集合中每个元素的所有子元素。 .closest() 从元素本身开始,逐级向上级元素 ...
分类:
Web程序 时间:
2016-07-25 16:07:33
阅读次数:
397
// When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `s ...
分类:
移动开发 时间:
2016-07-24 22:32:57
阅读次数:
274
16. 3Sum Closest 16. 3Sum Closest Total Accepted: 85780 Total Submissions: 289017 Difficulty: Medium Given an array S of n integers, find three intege ...
分类:
其他好文 时间:
2016-07-23 16:32:58
阅读次数:
101