CF1810B.Candies

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This problem is about candy. Initially, you only have 11 candy, and you want to have exactly nn candies.

You can use the two following spells in any order at most 4040 times in total.

  • Assume you have xx candies now. If you use the first spell, then xx candies become 2x12x-1 candies.
  • Assume you have xx candies now. If you use the second spell, then xx candies become 2x+12x+1 candies.

Construct a sequence of spells, such that after using them in order, you will have exactly nn candies, or determine it's impossible.

输入格式

Each test contains multiple test cases. The first line contains a single integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases. Their description follows.

Each test case contains one line with a single integer nn ( 2n1092 \le n \le 10^9 ) — the required final number of candies.

输出格式

For each test case, output the following.

If it's possible to eventually have nn candies within 4040 spells, in the first line print an integer mm ( 1m401 \le m \le 40 ), representing the total number of spells you use.

In the second print mm integers a1,a2,,ama_{1}, a_{2}, \ldots, a_{m} ( aia_{i} is 11 or 22 ) separated by spaces, where ai=1a_{i} = 1 means that you use the first spell in the ii -th step, while ai=2a_{i} = 2 means that you use the second spell in the ii -th step.

Note that you do not have to minimize mm , and if there are multiple solutions, you may output any one of them.

If it's impossible, output 1-1 in one line.

输入输出样例

  • 输入#1

    4
    2
    3
    7
    17

    输出#1

    -1
    1
    2 
    2
    2 2 
    4
    2 1 1 1

说明/提示

For n=3n=3 , you can just use the second spell once, and then have 21+1=32 \cdot 1 + 1 = 3 candies.

For n=7n=7 , you can use the second spell twice. After the first step, you will have 33 candies. And after the second step, you will have 23+1=72 \cdot 3 + 1 = 7 candies.

首页