手机网站 禁止缩放,网站建设 技术,js商城网站,免费网站建设排名一、题目 二、题解#xff1a; 1、对于这道题#xff0c;题意为让我们寻找一个数x使得
b[i]a[i]^x#xff0c; 并且b[1]^b[2]^b[3]^ b[4]^b[5]....0 2、我们把b[i]给拆开#xff0c;可以得到 3、又因为^满足结合律#xff0c;因此#xff0c;可以把括号给拆开 4、接着…一、题目 二、题解 1、对于这道题题意为让我们寻找一个数x使得
b[i]a[i]^x 并且b[1]^b[2]^b[3]^ b[4]^b[5]....0 2、我们把b[i]给拆开可以得到 3、又因为^满足结合律因此可以把括号给拆开 4、接着因为x^x0,所以原式可以化简为题目中有提到x为奇数个 5、因为0^xx所以可以对等号两边同时求异或^ 因此我们可以发现所需要求的x即是所有的a[i]同时取异或
三、完整代码如下:
#include bits/stdc.h
using namespace std;typedef long long ll;
const int N 2e57; // 定义最大范围
int a[N];void solve()
{int res 0; //用来存储答案int n; cin n;for (int i 1; i n; i) cin a[i];for (int i 1; i n; i){res ^ a[i];}cout res \n;
}int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int _ 1; cin _;while (_--) solve();system(pause);return 0;
}