CF2246B.ezraft and Array

入门

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given a single integer n.n. Construct an array of nn distinct positive integers a1,…,ana_1, \ldots, a_n such that for all i (1≤i≤n)i \, (1 \le i \le n), a1+a2+a3+…+ana_1 + a_2 + a_3 + \ldots + a_n is divisible by ai,a_i, or determine that no such array exists.

给你一个正整数 nn。请构造一个由 nn 个互不相同的正整数组成的数组 a1,…,ana_1, \ldots, a_n,使得对所有 i (1≤i≤n)i\ (1 \le i \le n),和 a1+a2+a3+…+ana_1 + a_2 + a_3 + \ldots + a_n 都能被 aia_i 整除;或者判断这样的数组不存在。

输入格式

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

The first and only line of each test case contains a single integer n (1≤n≤50).n \, (1 \le n \le 50).

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

每个测试用例仅有一行,包含一个整数 nn(1≤n≤501 \le n \le 50)。

输出格式

For each test case, if there is no solution, output a single integer −1-1.

Otherwise, output nn integers a1,…,an (1≤ai≤1017)a_1, \ldots, a_n \, (1 \le a_i \le 10^{17}) — an array satisfying the conditions.

If there are multiple solutions, print any of them.

对于每个测试用例,若无解,则输出单个整数 −1-1。

否则,输出 nn 个整数 a1,…,an (1≤ai≤1017)a_1, \ldots, a_n \, (1 \le a_i \le 10^{17}) —— 一个满足条件的数组。

若存在多个解,输出任意一个即可。

输入输出样例

  • 输入#1

    3
    1
    4
    5

    输出#1

    1
    1 9 2 6
    12 3 10 20 15

说明/提示

In the first test case, the condition is clearly satisfied, since 11 is divisible by itself.

In the second test case, the output is a=[1,9,2,6].a = [1,9,2,6]. We have a1+a2+a3+a4=18,a_1 + a_2 + a_3 + a_4 = 18, which is divisible by all ai.a_i.

在第一个测试用例中,条件显然满足,因为 11 能被其自身整除。

在第二个测试用例中,输出为 a=[1,9,2,6]a = [1,9,2,6]。我们有 a1+a2+a3+a4=18a_1 + a_2 + a_3 + a_4 = 18,该和能被所有 aia_i 整除。

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

首页