Cheerio Contest 3 P3 - Everything Array
View as PDFConsider an array where each integer from  to 
 (inclusive) can be made by either adding or subtracting 
 numbers in the array. More rigorously, for every integer 
 there exists two indices 
 
 such that 
 or 
. Furthermore, each array element must be an integer in the range 
, though they do not have to be distinct.
Your goal is to find and construct such an array with a length of at most .
Constraints
| Points Awarded | ||
|---|---|---|
| 6 points | ||
| 9 points | 
Input Specification
The only line of input contains two integers  and 
.
Output Specification
The first line should contain an integer , the length of the array 
 you have found.
The next line should contain  integers 
 
, the elements of the array.
Sample Input
18 7
Sample Output
7
2 3 16 4 8 5 13
Comments