#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
int T;
int depth, num;
scanf("%d" ,&T);
while (T-- > 0)
{
scanf("%d%d", &depth, &num);
int flag = 1 << (depth-1);
int pos = 1;
while (pos < flag)
{
pos = (num&1) ? (pos<<1) : ((pos<<1) + 1);
num = (num&1) ? ((num+1)>>1) : (num>>1);
}
printf("%d\n", pos);
}
int x;
scanf("%d", &x);
return 0;
}
ACM篇:Uva 679 -- Droping Balls
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.