刚入谷萌新求助
查看原帖
刚入谷萌新求助
973480
封禁用户楼主2024/5/30 09:33
#include<bits/stdc++.h>
using namespace std;
int depth=4;
int k=2;
int ans=0;
bool value[1<<20]={false};
void dfs(int x){
    if(x>=(1<<(depth-1))){
        ans=x;
        return;
    }
    if(value[x]==false){
        value[x]=true;
        dfs(2*x);
    }else{
        value[x]=false;
        dfs(2*x+1);
    }
}
int main(){
    int t;
    cin >> t;
    for(int i=1;i<=t;i++){
        cin >> depth >> k;
        for(int i=1;i<=k;i++){
            dfs(1);
        }
        cout << ans << endl;
        ans=0;
    }
    return 0;
}
2024/5/30 09:33
加载中...