Consider an infinite full binary search tree (see the figure below), the numbers in the nodes are 1, 2, 3, .... In a subtree whose root node is X, we can get the minimum number in this subtree by repeating going down the left node until the last level, and we can also find the maximum number by going down the right node. Now you are given some queries as "What are the minimum and maximum numbers in the subtree whose root node is X?" Please try to find answers for there queries. 

Input

In the input, the first line contains an integer N, which represents the number of queries. In the next N lines, each contains a number representing a subtree with root number X (1 <= X <= 2 31 - 1).

Output

There are N lines in total, the i-th of which contains the answer for the i-th query.

Sample Input

2
8
10

Sample Output

1 15
9 11 https://blog.csdn.net/fengkuangdewoniudada/article/details/69660755
规律请看这篇博客
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
#define pi acos(-1.0)
#define eps 1e-6
#define fi first
#define se second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define bug printf("******\n")
#define mem(a,b) memset(a,b,sizeof(a))
#define fuck(x) cout<<"["<<x<<"]"<<endl
#define f(a) a*a
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pf printf
#define FRE(i,a,b) for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b) for(i = a; i < b; i++)
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define FIN freopen("DATA.txt","r",stdin)
#define lowbit(x) x&-x
#pragma comment (linker,"/STACK:102400000,102400000") using namespace std;
typedef long long LL; int main() {
int t, n;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
int k=lowbit(n);
printf("%d %d\n",n-k+,n+k-);
}
return ;
}

最新文章

  1. “LC.exe”错误
  2. (转)JS Date格式化为yyyy-MM-dd类字符串
  3. 简单实用的PHP防注入类实例
  4. GridView使用自带分页功能时分页方式及样式PagerStyle
  5. Page和UserControl的事件加载顺序
  6. sql 去除重复记录
  7. ImagXpress中如何修改Alpha通道方法汇总
  8. FZU 8月有奖月赛A Daxia &amp; Wzc&#39;s problem (Lucas)
  9. 解析搜狗词库(python)
  10. Spring初学(一)
  11. 使用更清晰DebugLog开发和调试工具
  12. document.form.command.value
  13. 学习笔记TF035:实现基于LSTM语言模型
  14. 【移动开发】Service类onStartCommand()返回值和参数
  15. 浅谈C++中的友元关系
  16. 《java入门第一季》之泛型方法和泛型接口
  17. number类型精度分析
  18. 小技巧——病毒分析中关闭ASLR
  19. Wireshark&#160;wireshake数据包分割及捕包过滤器介绍
  20. [CF1017G]The Tree[树链剖分+线段树]

热门文章

  1. ionic 日期插件学习
  2. selenium常用操作方法
  3. 【Linux 运维】linux系统修改主机名
  4. ubuntu samba配置注意事项
  5. 线性代数之——微分方程和 exp(At)
  6. LeetCode 107 ——二叉树的层次遍历 II
  7. Linux查看物理CPU个数,核数,逻辑CPU个数;内存信息
  8. Beta版本软件使用说明
  9. c# windows service 程序
  10. ubuntu上的inpack测试