A - ^&^

Bit operation is a common computing method in computer science ,Now we have two positive integers AA and BB ,Please find a positive integer CC that minimize the value of the formula (A  xor  C)  &  (B  xor  C)(A  xor  C)  &  (B  xor  C) .Sometimes we can find a lot of CC to do this ,So you need to find the smallest CC that meets the criteria .

For example ,Let's say AA is equal to 5 and BB is equal to 3 ,we can choose CC=1,3.... ,so the answer we're looking for CC is equal to 1.

If the value of the expression is 0 when C=0, please print 1. 

Input

The input file contains TT test samples.(1<=TT<=100)

The first line of input file is an integer TT.

Then the TT lines contains 2 positive integers, AA and BB, (1≤A,B<2321≤A,B<232)OutputFor each test case,you should output the answer and a line for each answer. 
Sample Input

1
3 5

Sample Output

1

   由题意:找到最小C,使(A xor C)&(B xor C)最小。根据分配律,原式=(A&B) xor C;
   A,B已知,则(A&B)为固定值,又根据xor(异或)知识:同为0,异为1,则要想使原式最小,C要==(A&B)才行,因为两个数异或运算,如果两个数相同,同为0,结果最小。
所以C=(A&B)。
  又根据题意最后一句:If the value of the expression is 0 when C=0, please print 1. 
    有代码:
    
#include<iostream>
typedef long long ll;
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll a,b;
cin>>a>>b;
if((a&b)==)
printf("1\n");
else
printf("%lld\n",a&b);
}
}

2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 A题的更多相关文章

  1. [BFS,A*,k短路径] 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 path (Problem - 6705)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=6705 path Time Limit: 2000/2000 MS (Java/Others)    Mem ...

  2. [贪心,dp] 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 Fishing Master (Problem - 6709)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=6709 Fishing Master Time Limit: 2000/1000 MS (Java/Othe ...

  3. 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛(8/11)

    $$2019中国大学生程序设计竞赛(CCPC)\ -\ 网络选拔赛$$ \(A.\hat{} \& \hat{}\) 签到,只把AB都有的位给异或掉 //#pragma comment(lin ...

  4. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  5. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 F题 Clever King(最小割)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  6. 【赛后总结+部分题解】2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛

    赛后总结: T:今天状态一般,甚至有点疲惫.然后12点比赛开始,和队友开始看题,从最后往前面看,发现数学题公式看不懂.然后发现队友已经双开做1001和1006了,我看着1007有人A,开始做1007. ...

  7. 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛

    传送门 A.^&^ 题意: 找到最小的正数\(C\),满足\((A\ xor\ C)\&(B\ xor \ C)\)最小. 思路: 输出\(A\&B\)即可,特判答案为0的情况 ...

  8. 【2019中国大学生程序设计竞赛-女生专场】C - Function

    原题 韦神提供的思路orz 首先一个显然的性质,所有的c可以提出来,方程变成ax^2+bx的形式 因为x的值是离散的,而m的值又不大 所以一开始让x都为1(注意!x是正整数),然后每次挑一个x让他加一 ...

  9. 2019中国大学生程序设计竞赛-女生专场(重现赛)部分题解C-Function(贪心+优先队列) H-clock(模拟)

    Function 题目链接 Problem Description wls 有 n 个二次函数 Fi(x) = aix2 + bix + ci (1 ≤ i ≤ n). 现在他想在∑ni=1xi = ...

随机推荐

  1. --转载 详细介绍java中的数据结构

    http://developer.51cto.com/art/201107/273003.htm 也许你已经熟练使用了java.util包里面的各种数据结构,但是我还是要说一说java版数据结构与算法 ...

  2. 前端解析返回的对象时json显示$ref问题的解决

    在mapper中写的语句,结果集中association,采用的一个对象,整个list列表中每个元素有一个对象元素,如果第二个元素中有一个与第一个元素中对象同名的,就会去引用上一个元素的地址,在jso ...

  3. EBP寻址

    一.EBP寻址 ESP:栈顶指针 (程序对与堆栈的使用 使用到哪里,esp就是哪里) EBP:  栈底指针 之前都是借用ESP去寻址确定一些参数 ,但如果存到堆栈里面的值过多,那么就得不断地调整ESP ...

  4. 056-for循环中continue的使用

    <?php ; $i <= ; $i++) { //for循环输出数值 == ) //判断变量是否为3的整数倍 { continue;//跳过本次循环剩余语句 } echo "$ ...

  5. 二、【未来】React环境安装:npx

    搭建React的开发环境的第二种方法(新-未来推荐): https://reactjs.org/docs/create-a-new-react-app.html 一. npx简介: 1. npm v5 ...

  6. linux项目,项目报错,排查

    今天在遇到以前部署的项目突然没有数据了,然后就去服务器看了一下,打印日志发现报错了,现在我是一脸懵逼,因为不知道怎么排查 然后同事告诉说先看报错的原因,然后再去找认识的类,我打码的都是一些认识的 然后 ...

  7. jQuery文档加载事件

    $(document).ready(handler) $().ready(handler) (this is not recommended) $(handler) 相当于: $(document). ...

  8. tx2系统备份与恢复

    https://blog.csdn.net/ycy_dy/article/details/80493392 https://blog.csdn.net/piaopiaopiaopiaopiao/art ...

  9. ESP32-DOWDQ6蓝牙&Wifi 两个可单独控制的 CPU 内核

    乐鑫(Espressif Systems)研发设计IoT业内集成度最高.性能最稳定.功耗最低的无线系统级芯片. ESP32-D0WDQ6集成无线2.4 GHz Wi-Fi和蓝牙双模的单芯片方案,具有两 ...

  10. Standard Aras Dialogs

    In a another blog post, we covered how to open dialogs within Aras Innovator using custom forms and ...