题意:
给定一棵树和m个询问 每个询问要求回答不在u和v两节点所形成的路径上的点的最小标号
思路:
一开始以为是LCA… 不过T了好几次… 后来发现不用LCA也可做
考虑每个询问u和v 如果他们的lca不是1 则1一定是答案 不过求lca会T 那么我们只需要在遍历树的时候给节点染色 染的颜色就是1的儿子的颜色 如果x这个点在y的子树中(y是1的儿子)那么他的颜色就是y
...
分类:
其他好文 时间:
2014-08-09 21:33:29
阅读次数:
213
解法一:若二进制末尾为1,则除以2余1;int count(int a){ int num=0; while(a) { if(a%2==1) ++num; a=a/2; } return num;}解法二:使用移位操作相...
分类:
其他好文 时间:
2014-08-09 21:26:59
阅读次数:
289
由于数据太多为了加快检索将一个表建为分区表在数据插入是动态添加临时表as -- Local variables here fq_dm varchar(30); p_count number; -- p_fadm number; p_sql varchar(100);begin -- Tes...
分类:
数据库 时间:
2014-08-09 21:15:49
阅读次数:
359
阶乘因式分解(二)时间限制:3000ms | 内存限制:65535KB难度:3描述给定两个数n,m,其中m是一个素数。将n(0int main( ){ int count,n,m,i,ii,t; scanf("%d",&t); while(t--) { count=0; scanf(...
分类:
其他好文 时间:
2014-08-09 21:11:19
阅读次数:
247
1的个数时间限制:3000ms | 内存限制:65535KB难度:1描述小南刚学了二进制,他想知道一个数的二进制表示中有多少个1,你能帮他写一个程序来完成这个任务吗?输入第一行输入一个整数N,表示测试数据的组数(1int main(){ int m,N,count ;scanf("%d",&N);w...
分类:
其他好文 时间:
2014-08-09 21:09:49
阅读次数:
240
public member function
std::vector::front
reference front();
const_reference front() const;
Access first element
访问第一个元素
Returns a reference to the first element in the vector....
分类:
其他好文 时间:
2014-08-09 18:45:48
阅读次数:
243
HTML: 1 2 3 canvas画圆 4 5 6 7 8 你的浏览器不支持canvas 9 10 11 JS: 1 var a=0,//确定图形的旋转角度变量 2 count= 0,//确定圆的个数 3 colors=[];//...
分类:
其他好文 时间:
2014-08-09 18:32:08
阅读次数:
192
Description
Count the Trees
Another common social inability is known as ACM (Abnormally Compulsive Meditation). This psychological disorder is somewhat common among programm...
分类:
其他好文 时间:
2014-08-09 16:03:08
阅读次数:
296
Given a string S and a string T, count the number of distinct subsequences of T in S.
A subsequence of a string is a new string which is formed from the original string by deleting some (can be non...
分类:
其他好文 时间:
2014-08-09 13:30:47
阅读次数:
211
//sql过滤关键字 public static bool CheckKeyWord(string sWord) { //过滤关键字 string StrKeyWord = @"select|insert|delete|from|count\(|drop tabl...
分类:
数据库 时间:
2014-08-09 13:10:17
阅读次数:
357