Preparando MOJI

Ehab the Xorcist

1000ms 262144K

Description:

Given 2 integers $$$u$$$ and $$$v$$$, find the shortest array such that bitwise-xor of its elements is $$$u$$$, and the sum of its elements is $$$v$$$.

Input:

The only line contains 2 integers $$$u$$$ and $$$v$$$ $$$(0 \le u,v \le 10^{18})$$$.

Output:

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

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

Sample Input:

2 4

Sample Output:

2
3 1

Sample Input:

1 3

Sample Output:

3
1 1 1

Sample Input:

8 5

Sample Output:

-1

Sample Input:

0 0

Sample Output:

0

Note:

In the first sample, $$$3\oplus 1 = 2$$$ and $$$3 + 1 = 4$$$. There is no valid array of smaller length.

Notice that in the fourth sample the array is empty.

Informação

Codeforces

Provedor Codeforces

Código CF1325D

Tags

bitmasksconstructive algorithmsgreedynumber theory

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 10:00:15

Relacionados

Nada ainda