307234: CF1325D. Ehab the Xorcist
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Ehab the Xorcist
题意翻译
给定整数 $u$ 和 $v(0\le u,v \le 10^{18})$,试构造长度最短的数组,使得数组内所有元素的异或和为 $u$,加和为 $v$。 如果有解,输出两行,第一行输出一个整数 $n$,第二行输出 $n$ 个非负整数,表示数组里的元素。多解输出任意一组即可。如果无解,输出一行一个整数 $-1$。题目描述
Given 2 integers $ u $ and $ v $ , find the shortest array such that [bitwise-xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of its elements is $ u $ , and the sum of its elements is $ v $ .输入输出格式
输入格式
The only line contains 2 integers $ u $ and $ v $ $ (0 \le u,v \le 10^{18}) $ .
输出格式
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.
输入输出样例
输入样例 #1
2 4
输出样例 #1
2
3 1
输入样例 #2
1 3
输出样例 #2
3
1 1 1
输入样例 #3
8 5
输出样例 #3
-1
输入样例 #4
0 0
输出样例 #4
0