CF1864A.Increasing and Decreasing

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given three integers xx, yy, and nn.

Your task is to construct an array aa consisting of nn integers which satisfies the following conditions:

  1. a1=xa_1=x, an=ya_n=y;
  2. aa is strictly increasing (i.e. a1<a2<…<ana_1 \lt a_2 \lt \ldots \lt a_n);
  3. if we denote bi=ai+1−aib_i=a_{i+1}-a_{i} for 1≤i≤n−11 \leq i \leq n-1, then bb is strictly decreasing (i.e. b1>b2>…>bn−1b_1 \gt b_2 \gt \ldots \gt b_{n-1}).

If there is no such array aa, print a single integer −1-1.

给你三个整数 xx、yy 和 nn。

你的任务是构造一个由 nn 个整数组成的数组 aa,使其满足以下条件:

  1. a1=xa_1=x,an=ya_n=y;
  2. aa 是严格递增的(即 a1<a2<…<ana_1 \lt a_2 \lt \ldots \lt a_n);
  3. 若记 bi=ai+1−aib_i=a_{i+1}-a_{i}(其中 1≤i≤n−11 \leq i \leq n-1),则 bb 是严格递减的(即 b1>b2>…>bn−1b_1 \gt b_2 \gt \ldots \gt b_{n-1})。

如果不存在满足上述条件的数组 aa,则输出单个整数 −1-1。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤10001 \le t \le 1000). The description of the test cases follows.

The only line of each test case contains three integers xx, yy, nn (1≤x<y≤1000,3≤n≤10001 \le x \lt y \le 1000,3 \le n \le 1000).

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤10001 \le t \le 1000)。随后是测试用例的描述。

每个测试用例仅有一行,包含三个整数 xx、yy、nn(1≤x<y≤10001 \le x \lt y \le 1000,3≤n≤10003 \le n \le 1000)。

输出格式

For each test case, output nn integers a1,a2,…,ana_1,a_2,\ldots,a_n. If there are multiple solutions, print any of them.

If there is no solution, print a single integer −1-1.

对于每个测试用例,输出 nn 个整数 a1,a2,…,ana_1,a_2,\ldots,a_n。如果存在多个解,输出任意一个即可。

如果无解,则输出单个整数 −1-1。

输入输出样例

  • 输入#1

    3
    1 4 3
    1 3 3
    100 200 4

    输出#1

    1 3 4
    -1
    100 150 180 200

说明/提示

In the first test case, a=[1,3,4]a=[1,3,4], which is strictly increasing. Next, b1=a2−a1=3−1=2b_1=a_2-a_1=3-1=2, b2=a3−a2=4−3=1b_2=a_3-a_2=4-3=1, thus b=[2,1]b=[2,1], which is strictly decreasing.

In the second test case, there is no array aa that satisfies all the conditions above.

在第一个测试用例中,a=[1,3,4]a=[1,3,4],该数组严格递增。接着,b1=a2−a1=3−1=2b_1=a_2-a_1=3-1=2,b2=a3−a2=4−3=1b_2=a_3-a_2=4-3=1,因此 b=[2,1]b=[2,1],该数组严格递减。

在第二个测试用例中,不存在满足上述所有条件的数组 aa。

输入解题思路,AI测评打分。不知道怎么写?

首页