The Description Of Problem:
A. XORwice
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game.
Tzuyu gave Sana two integers a and b and a really important quest.
In order to complete the quest, Sana has to output the smallest possible value of (a⊕x) + (b⊕x) for any given x, where ⊕ denotes the bitwise XOR operation.
Input
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). Description of the test cases follows.
The only line of each test case contains two integers a and b (1≤a,b≤109).
Output
For each testcase, output the smallest possible value of the given expression.
Example:
input:
6
6 12
4 9
59 832
28 14
4925 2912
1 1
output:
10
13
891
18
6237
0
My Answer Code:
/*
Author:Albert Tesla Wizard
Time:2020/10/24 15:42
*/
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
vector<vector<ull>>a(t,vector<ull>(2));
vector<ull>ans(t);
for(int i=0;i<t;i++)
{
cin>>a[i][0]>>a[i][1];
}
for(int i=0;i<t;i++)
{
int Min=min(a[i][0],a[i][1]);
ans[i]=(a[i][0]^Min)+(a[i][1]^Min);
}
for(int i=0;i<t;i++)cout<<ans[i]<<'\n';
return 0;
}
CodeForces 1421-A XORwice
猜你喜欢
转载自blog.csdn.net/AlberTesla/article/details/109260555
今日推荐
周排行