GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday, 5 June 2022

[Solution] Simple XOR CodeChef Solution | CodeChef Problem Solution 2022

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

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

  • a1⊕a2⊕a3⊕a4=0
  • L≤a1,a2,a3,a4≤R
  • ai=aj if and only if i=j
Solution Click Below:-  CLICK HERE


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

Input Format

  • 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

  • 1≤T≤1000
  • 1≤L,R≤109
  • L+3≤R, so there are at least four distinct integers in the range.

No comments:

Post a Comment