CF1166D.Cute Sequences

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Given a positive integer mm , we say that a sequence x1,x2,,xnx_1, x_2, \dots, x_n of positive integers is mm -cute if for every index ii such that 2in2 \le i \le n it holds that xi=xi1+xi2++x1+rix_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i for some positive integer rir_i satisfying 1rim1 \le r_i \le m .

You will be given qq queries consisting of three positive integers aa , bb and mm . For each query you must determine whether or not there exists an mm -cute sequence whose first term is aa and whose last term is bb . If such a sequence exists, you must additionally find an example of it.

输入格式

The first line contains an integer number qq ( 1q1031 \le q \le 10^3 ) — the number of queries.

Each of the following qq lines contains three integers aa , bb , and mm ( 1a,b,m10141 \le a, b, m \le 10^{14} , aba \leq b ), describing a single query.

输出格式

For each query, if no mm -cute sequence whose first term is aa and whose last term is bb exists, print 1-1 .

Otherwise print an integer kk ( 1k501 \le k \leq 50 ), followed by kk integers x1,x2,,xkx_1, x_2, \dots, x_k ( 1xi10141 \le x_i \le 10^{14} ). These integers must satisfy x1=ax_1 = a , xk=bx_k = b , and that the sequence x1,x2,,xkx_1, x_2, \dots, x_k is mm -cute.

It can be shown that under the problem constraints, for each query either no mm -cute sequence exists, or there exists one with at most 5050 terms.

If there are multiple possible sequences, you may print any of them.

输入输出样例

  • 输入#1

    2
    5 26 2
    3 9 1
    

    输出#1

    4 5 6 13 26
    -1
    

说明/提示

Consider the sample. In the first query, the sequence 5,6,13,265, 6, 13, 26 is valid since 6=5+16 = 5 + \bf{\color{blue} 1} , 13=6+5+213 = 6 + 5 + {\bf\color{blue} 2} and 26=13+6+5+226 = 13 + 6 + 5 + {\bf\color{blue} 2} have the bold values all between 11 and 22 , so the sequence is 22 -cute. Other valid sequences, such as 5,7,13,265, 7, 13, 26 are also accepted.

In the second query, the only possible 11 -cute sequence starting at 33 is 3,4,8,16,3, 4, 8, 16, \dots , which does not contain 99 .

首页