CF BUDDY
← Problems·

1325D · Ehab the Xorcist

1700 · bitmasks, constructive algorithms, greedy

Problem: Given 2 integers uu and vv, find the shortest array such that bitwise-xor of its elements is uu, and the sum of its elements is vv.

Input Format: The only line contains 2 integers uu and vv (0u,v1018)(0 \le u,v \le 10^{18}).

Output Format: If there's no array that satisfies the condition, print "-1". Otherwise:

The first line should contain one integer, nn, representing the length of the desired array. The next line should contain nn positive integers, the array itself. If there are multiple possible answers, print any.

Note: In the first sample, 31=23\oplus 1 = 2 and 3+1=43 + 1 = 4. There is no valid array of smaller length.

Notice that in the fourth sample the array is empty.

Sample Cases

Case 1

Input

2 4

Output

2
3 1

Case 2

Input

1 3

Output

3
1 1 1

Case 3

Input

8 5

Output

-1

Case 4

Input

0 0

Output

0

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback