Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
43260 范墨涵 【J】T2 C++ 通过 100 245 MS 248 KB 597 2026-10-28 13:58:35

Tests(10/10):


#include<bits/stdc++.h> using namespace std; #define int long long int t; int n,x; signed main(){ //freopen("xor.in","r",stdin); //freopen("xor.out","w",stdout); cin >> t; while (t--){ cin >> n >> x; if (n==1 and x==0){ cout << -1 << '\n'; continue; } if (x==0){ if (n%2==0) cout << n; else cout << n+3; cout << '\n'; continue; } int cnt=0,x1=x; while (x1>0){ cnt+=x1%2; x1/=2; } if (n<=cnt) cout << x; else if ((n-cnt)%2==0)cout << x+n-cnt; else if ((n-cnt)%2==1) cout << x+n-cnt+1; cout << '\n'; } return 0; }


测评信息: