CodeForces 1421-A XORwice

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;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值