poerhfsdhfnc_h's blog

By poerhfsdhfnc_h, history, 3 years ago, In English

You are given two arrays a and b each of size n. For each i (0<=i<n), you have to find smallest 'x' such that

-> x+y = a[i]

-> x^y = b[i] (i.e. x xor y = b[i])

0<=a[i],b[i]<=10^(15)

1<=n<=50

It is possible that there might be no 'x' possible. Would be glad if anyone could help...

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It is possible

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

By x^y do you mean power or the bitwise operator?

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Use this property :- (x + y) = (x ^ y) + 2*(x & y)