CF1443A.Kids Seating
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Today the kindergarten has a new group of n kids who need to be seated at the dinner table. The chairs at the table are numbered from 1 to 4n. Two kids can't sit on the same chair. It is known that two kids who sit on chairs with numbers a and b (a=b) will indulge if:
- gcd(a,b)=1 or,
- a divides b or b divides a.
gcd(a,b) — the maximum number x such that a is divisible by x and b is divisible by x.
For example, if n=3 and the kids sit on chairs with numbers 2, 3, 4, then they will indulge since 4 is divided by 2 and gcd(2,3)=1. If kids sit on chairs with numbers 4, 6, 10, then they will not indulge.
The teacher really doesn't want the mess at the table, so she wants to seat the kids so there are no 2 of the kid that can indulge. More formally, she wants no pair of chairs a and b that the kids occupy to fulfill the condition above.
Since the teacher is very busy with the entertainment of the kids, she asked you to solve this problem.
今天幼儿园迎来了一群新入园的 n 个小朋友,需要安排他们坐在餐桌旁。餐桌旁的椅子编号从 1 到 4n。每个椅子至多坐一个小朋友。已知:若两个小朋友分别坐在编号为 a 和 b(a=b)的椅子上,则他们会“闹腾”(indulge),当且仅当满足以下任一条件:
- gcd(a,b)=1,或
- a 整除 b,或 b 整除 a。
其中,gcd(a,b) 表示最大的正整数 x,使得 x 同时整除 a 和 b。
例如,当 n=3 时,若小朋友坐在编号为 2、3、4 的椅子上,则他们会闹腾,因为 4 被 2 整除,且 gcd(2,3)=1;而若小朋友坐在编号为 4、6、10 的椅子上,则他们不会闹腾。
老师非常不希望餐桌上出现混乱局面,因此她希望安排座位,使得任意两个小朋友都不会闹腾。更准确地说,她要求:所有被小朋友占据的椅子编号构成的集合中,不存在任何一对编号 a 和 b 满足上述任一闹腾条件。
由于老师正忙于陪小朋友们玩耍,她请你来解决这个问题。
输入格式
The first line contains one integer t (1≤t≤100) — the number of test cases. Then t test cases follow.
Each test case consists of one line containing an integer n (1≤n≤100) — the number of kids.
第一行包含一个整数 t(1≤t≤100)—— 测试用例的数量。随后是 t 个测试用例。
每个测试用例由一行组成,包含一个整数 n(1≤n≤100)—— 小孩的数量。
输出格式
Output t lines, which contain n distinct integers from 1 to 4n — the numbers of chairs that the kids should occupy in the corresponding test case. If there are multiple answers, print any of them. You can print n numbers in any order.
输出 t 行,每行包含 n 个互不相同的整数,取值范围为 1 到 4n —— 这些整数表示对应测试用例中孩子们应坐的椅子编号。若存在多种答案,输出任意一种即可。每行的 n 个数字可以以任意顺序输出。
输入输出样例
输入#1
3 2 3 4
输出#1
6 4 4 6 10 14 10 12 8
输入解题思路,AI测评打分。不知道怎么写?