1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #include <bits/stdc++.h> #define ios ios::sync_with_stdio(0),cin.tie(0) using namespace std; int n,m,tree[3000];
int drop(int id){ if(id>=(1<<(n-1)))return id; tree[id]=!tree[id]; if(!tree[id])return drop(2*id+1); else return drop(2*id); }
int main(){ ios; int t;cin>>t; while(t--){ int ans = 0;cin>>n>>m; memset(tree,0,sizeof(tree)); for(int i=0;i<m;i++){ ans = drop(1); } cout<<ans<<endl; } }
|