Prime Xor CodeChef Solution


Prime Xor CodeChef Solution

Prime Xor CodeChef Solution

For 33 distinct prime integers A,B,A,B, and CC (1<A,B,C<230)(1<A,B,C<230), we define positive integers X,Y,X,Y, and ZZ as:
X=A⊕B,Y=B⊕C,X=A⊕B,Y=B⊕C, and Z=C⊕AZ=C⊕A, where ⊕⊕ denotes the bitwise XOR operation.

Given only two integers XX and YY and the fact that at least one integer amongst X,Y,X,Y, and ZZ is odd, find the values of A,B,A,B, and CC.


  • You need to print the integers A,B,A,B, and CC in ascending order.
  • It is guaranteed in the input that a unique answer exists.

Prime Xor CodeChef Solution

Input Format

  • The first line contains one integer TT — the number of test cases. Then TT test cases follow.
  • Each test case consists of one line which contains 22 integers XX and YY.

Output Format

  • For each test case, print 33 integers — A,B,A,B, and CC in ascending order where (1<A,B,C<230)(1<A,B,C<230).


  • 1≤T≤1051≤T≤105
  • 1≤X,Y<2301≤X,Y<230

Sample Input 1 

1 6
9 15

Sample Output 1 

2 3 5
2 11 13


Prime Xor CodeChef Solution

Test Case 11: The answer is A=2,B=3,C=5A=2,B=3,C=5. Thus, X=2⊕3=1,Y=3⊕5=6,Z=2⊕5=7X=2⊕3=1,Y=3⊕5=6,Z=2⊕5=7. Note that XX and YY are same as mentioned in input and the values XX as well as ZZ are odd.

Test Case 22: The answer is A=11,B=2,C=13A=11,B=2,C=13. Thus, X=11⊕2=9,Y=2⊕13=15,Z=11⊕13=6X=11⊕2=9,Y=2⊕13=15,Z=11⊕13=6. Note that XX and YY are same as mentioned in input and the values XX as well as YY are odd. Thus, the values of A,B,A,B, and CC in ascending order are 2,11,2,11, and 1313.


Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

2 thoughts on “Prime Xor CodeChef Solution

  1. I like what you guys are up too. Such smart work and reporting! Keep up the superb works guys I’ve incorporated you guys to my blogroll. I think it’ll improve the value of my site :).

Leave a Reply

Your email address will not be published.