class Result
{
private static long Solve(long a, long b)
long x = 0;
long y = 0;
long s = 1;
long overflow = 0;
while (a != 0 || b != 0)
if ((b & 1) == 1)
if ((a & 1) != 1-overflow)
return 0;
y |= s;
// v = v;
}
else // (b & 1) == 0
if ((a & 1) != overflow)
if (((a >> 1) & 1) == ((b >> 1) & 1))
// 0 0
overflow = 0;
else
// 1 1
x |= s;
overflow = 1;
a >>= 1;
b >>= 1;
s <<= 1;
return 2*x + 3*y;
/*
* Complete the 'bitwiseEquations' function below.
*
* The function is expected to return a LONG_INTEGER_ARRAY.
* The function accepts following parameters:
* 1. LONG_INTEGER_ARRAY a
* 2. LONG_INTEGER_ARRAY b
*/
public static List<long> bitwiseEquations(List<long> a, List<long> b)
return a.Zip(b, Solve).ToList();