Simple XOR solution codechef- You are given two integers L and R(L+3≤R). Output any four distinctintegers between L and R (inclusive) such that their bitwise XOR is zero.


Simple XOR solution codechef

You are given two integers L and R(L+3R). Output any four distinctintegers between L and R (inclusive) such that their bitwise XOR is zero.

More formally, output any four integers a1,a2,a3,a4 such that:

  • a1a2a3a4=0
  • La1,a2,a3,a4R
  • ai=aj if and only if i=j

If more than one such quadruple exists, you may output any of them. If no such quadruple exists, print 1 instead.

Input Format

Simple XOR solution codechef

  • The first line of input will contain a single integer T, the number of test cases. The description of the test cases follows.
  • Each test case consists of a single line of input, containing two space-separated integers L,R.

Output Format

For each testcase, output any four distinct integers between L and R such that their bitwise XOR is zero, or output 1 in case no such quadruple of four distinct integers exists.

Constraints

  • 1T1000
  • 1L,R109
  • L+3R, so there are at least four distinct integers in the range.

Sample Input 1

Simple XOR solution codechef

2
1 4
1 100

Sample Output 1

-1
3 6 9 12

Explanation

Test case 1: There are only four integers in the range and their bitwise XOR is not zero. 1234=4

Test case 2: There are many possible answers in this case. One of them is provided above: 3,6,9,12. It can be verified that 36912=0.

Solution

Click Here


Leave a Reply

Your email address will not be published. Required fields are marked *