摘要:
思路:除以2^k,找到商为奇数的位置,k为层数,有2^(k+1)-1个节点这里直接用位运算,x & -x 就求出 2^k 了。#includeusing namespace std;long lowbit(long x){ return x & -x;}int main(){ long n,x; c... 阅读全文
posted @ 2014-07-31 12:11
gongpixin
阅读(175)
评论(0)
推荐(0)
摘要:
思路:递归左子树、右子树#include#includeusing namespace std;char preord[30],inord[30];void recover(int preleft,int preright,int inleft,int inright){ int root,left... 阅读全文
posted @ 2014-07-31 10:38
gongpixin
阅读(167)
评论(0)
推荐(0)
摘要:
assert宏的原型定义在中,其作用是如果它的条件返回错误,则终止程序执行,原型定义:#include void assert( int expression ); assert的作用是现计算表达式 expression ,如果其值为假(即为0),那么它先向stderr打印一条出错信息,然后通过调... 阅读全文
posted @ 2014-07-31 10:17
gongpixin
阅读(238)
评论(0)
推荐(0)
摘要:
思路:一步一步往上走即可#includeusing namespace std;int main(){ int sc; cin>>sc; for(int s=1;s>a>>b; int left=0,right=0; while(1) { if(a>b) { int up=(a-... 阅读全文
posted @ 2014-07-31 09:38
gongpixin
阅读(213)
评论(0)
推荐(0)
浙公网安备 33010602011771号