| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 43248 | hanyihong | 【J】T2 | C++ | 通过 | 100 | 239 MS | 256 KB | 536 | 2026-10-28 13:57:38 |
#include<bits/stdc++.h> #define ll long long using namespace std; int T,n,x; ll ans; void sol(){ ll res=1; if(x==1&&n%2==0){cout<<n+3<<'\n';return;} if(n==1&&x==0){cout<<-1<<'\n';return;} if(n<=__builtin_popcount(x)){cout<<x<<'\n';return;} while(x){ if(x%2==1)ans+=res,n--; res*=2; x>>=1; } if(n%2==1)ans=ans+n+1; else ans+=n; cout<<ans<<'\n'; } signed main(){ cin>>T; while(T--){ cin>>n>>x,ans=0; sol(); } return 0; }