F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Claris and XOR

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1109    Accepted Submission(s): 523


Problem Description
Claris loves bitwise operations very much, especially XOR, because it has many beautiful features. He gets four positive integers $a,b,c,d$ that satisfies $a\leq b$ and $c\leq d$. He wants to choose two integers $x,y$ that satisfies $a\leq x\leq b$ and $c\leq y\leq d$, and maximize the value of $x~XOR~y$. But he doesn't know how to do it, so please tell him the maximum value of $x~XOR~y$.
 

Input
The first line contains an integer $T\left(1\leq T\leq10,000\right)$¡ª¡ªThe number of the test cases.
For each test case, the only line contains four integers $a,b,c,d\left(1\leq a,b,c,d\leq10^{18}\right)$. Between each two adjacent integers there is a white space separated.
 

Output
For each test case, the only line contains a integer that is the maximum value of $x~XOR~y$.
 

Sample Input
2 1 2 3 4 5 7 13 15
 

Sample Output
6 11
 

Hint

In the first test case, when and only when $x=2,y=4$, the value of $x~XOR~y$ is the maximum.
In the second test case, when and only when $x=5,y=14$ or $x=6,y=13$, the value of $x~XOR~y$ is the maximum.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 06:50:00, Gzip enabled