Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
43250 姜博睿 【J】T2 C++ 通过 100 234 MS 248 KB 474 2026-10-28 13:57:39

Tests(10/10):


#include <bits/stdc++.h> using namespace std; const int N=1e5+9; int T,n,x,cnt,t; int main(){ cin>>T; while(T--){ cin>>n>>x; cnt=0,t=x; while(t!=0){ cnt+=t%2; t/=2; } if(n==1&&x==0)cout<<"-1"<<endl; else if(cnt>=n)cout<<x<<endl; else if((n-cnt)%2==0)cout<<x+n-cnt<<endl; else if(x>=2)cout<<x+n-cnt+1<<endl; else cout<<n+3<<endl; } return 0; }


测评信息: