Determine numbers based on their sum and xor

假装没事ソ 提交于 2019-12-04 07:15:33

问题


If we know the sum and XOR of two numbers, then can we find out what are the two numbers?

I am trying to resolve a problem and the above problem is a part of that. Although, I do have another solution for that problem but I still want a solution for this.


回答1:


No.

Example: SUM=7, XOR=7
Possible answers:
a) 1, 6
b) 2, 5
c) 3, 4

Not enough information to decide which pair (a, b or c) is the original pair of numbers.



来源:https://stackoverflow.com/questions/25565626/determine-numbers-based-on-their-sum-and-xor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!