sak123's blog

By sak123, 4 weeks ago, In English

Alice and bob were performing n bit ripple carry adder operation on two numbers (x and y). Alice got the correct answer i.e, A but bob got the wrong answer i.e, B. After some time they got to know that bob was ignoring carry while performing the operation.

Given the values of A and B, your mission is to find out the values x and y.

You are given Q queries containing the values of A and B. Find the possible values of x and y. Refer the output section for more information

if there exist more than one solution output will be the pair (x,y) separated with the smallest possible x if there exists no solution then output -1

input:

2

4 2

3 4

output

1 3

-1

Can anyone help with the approach for this question?

 
 
 
 
  • Vote: I like it
  • +11
  • Vote: I do not like it