Quantcast
Channel: Given an XOR and SUM of two numbers, how to find the number of pairs that satisfy them? - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by dejvuth for Given an XOR and SUM of two numbers, how to find the...

Think of a+b = (a XOR b) + (a AND b)*2 as exactly what happen when you do binary addition. From your example, a = 010 and b = 111: 010 111 ---1001 = 101 + 100For each bit, you add bits from a and b...

View Article



Answer by Emil Vikström for Given an XOR and SUM of two numbers, how to find...

a AND b are the bits that are in both of the numbers. So these are doubled in the sum. a XOR b are the bits that are only present in one of the numbers so these should only be counted once in the...

View Article

Given an XOR and SUM of two numbers, how to find the number of pairs that...

I think the question may be a bit confusing. So, I'll try to explain it first.Let's say the XOR and SUM of two numbers are given. (Note that there are multiple pairs that may satisfy this.) For...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images