C. Yet Another Array Restoration

    科技2026-02-07  2

    time limit per test

    1 second

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    We have a secret array. You don't know this array and you have to restore it. However, you know some facts about this array:

    The array consists of nn distinct positive (greater than 00) integers.The array contains two elements xx and yy (these elements are known for you) such that x<yx<y.If you sort the array in increasing order (such that a1<a2<…<ana1<a2<…<an), differences between all adjacent (consecutive) elements are equal (i.e. a2−a1=a3−a2=…=an−an−1)a2−a1=a3−a2=…=an−an−1).

    It can be proven that such an array always exists under the constraints given below.

    Among all possible arrays that satisfy the given conditions, we ask you to restore one which has the minimum possible maximum element. In other words, you have to minimize max(a1,a2,…,an)max(a1,a2,…,an).

    You have to answer tt independent test cases.

    Input

    The first line of the input contains one integer tt (1≤t≤1001≤t≤100) — the number of test cases. Then tt test cases follow.

    The only line of the test case contains three integers nn, xx and yy (2≤n≤502≤n≤50; 1≤x<y≤501≤x<y≤50) — the length of the array and two elements that are present in the array, respectively.

    Output

    For each test case, print the answer: nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109), where aiai is the ii-th element of the required array. If there are several answers, you can print any (it also means that the order of elements doesn't matter).

    It can be proven that such an array always exists under the given constraints.

    Example

    input

    Copy

    5 2 1 49 5 20 50 6 20 50 5 3 8 9 13 22

    output

    Copy

    1 49 20 40 30 50 10 26 32 20 38 44 50 8 23 18 13 3 1 10 13 4 19 22 25 16 7

     

    解题说明:此题是一道数学题,按照题目意思可以发现数字最多为50个,于是可以直接从小到大枚举x~y之间的间距,看看最多能放几个数,再把剩下的数从 x往前放,多了再从y往后放。

    #include <stdio.h> int main() { long long int t, n, x, y, ans; scanf("%lld", &t); while (t--) { scanf("%lld %lld %lld", &n, &x, &y); int d = y - x; int diff; for (int i = 1; i <= d; i++) { if (d%i == 0) { diff = i; if (y - (n - 1)*i <= x) { break; } } } int start = y - (n - 1)*diff; while (start <= 0) { start += diff; } for (int i = 0; i<n; i++) { printf("%d ", start + (diff*i)); } printf("\n"); } return 0; }

     

    Processed: 0.013, SQL: 9