CF2246B.ezraft and Array
入门
通过率:0%
时间限制:1.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a single integer n. Construct an array of n distinct positive integers a1,…,an such that for all i(1≤i≤n), a1+a2+a3+…+an is divisible by ai, or determine that no such array exists.
给你一个正整数 n。请构造一个由 n 个互不相同的正整数组成的数组 a1,…,an,使得对所有 i (1≤i≤n),和 a1+a2+a3+…+an 都能被 ai 整除;或者判断这样的数组不存在。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤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).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤50)。随后是各测试用例的描述。
每个测试用例仅有一行,包含一个整数 n(1≤n≤50)。
输出格式
For each test case, if there is no solution, output a single integer −1.
Otherwise, output n integers a1,…,an(1≤ai≤1017) — an array satisfying the conditions.
If there are multiple solutions, print any of them.
对于每个测试用例,若无解,则输出单个整数 −1。
否则,输出 n 个整数 a1,…,an(1≤ai≤1017) —— 一个满足条件的数组。
若存在多个解,输出任意一个即可。
输入输出样例
输入#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 1 is divisible by itself.
In the second test case, the output is a=[1,9,2,6]. We have a1+a2+a3+a4=18, which is divisible by all ai.
在第一个测试用例中,条件显然满足,因为 1 能被其自身整除。
在第二个测试用例中,输出为 a=[1,9,2,6]。我们有 a1+a2+a3+a4=18,该和能被所有 ai 整除。
输入解题思路,AI测评打分。不知道怎么写?