poj 2309 BST

#include <iostream>        //第n层表示元素可以被2^n整除,从第0层开始,第n层的元素的subtree范围为a-(2^n-1) , a+(2^n-1)
#include <math.h>
using namespace std;
int main()
{
int n,count;
__int64 a,tmp;
cin
>>n;
while(n--)
{
cin
>>a;
tmp
=a;
count
=0;
while(tmp%2==0)
{
count
++;
tmp
=tmp/2;
}
cout
<<a-(__int64)pow(2.0,count)+1<<" "<<a+(__int64)pow(2.0,count)-1<<endl;
}
return 0;
}

  

posted on 2011-07-22 15:02  sysu_mjc  阅读(104)  评论(0编辑  收藏  举报

导航