P17533 [CodeChef] PERFPERM
提高-
题目描述

An index i in a permutation P of length N is said to be good if:
P_{i} is divisible by i

You are given 2 integers N and K. You need to construct a permutation P of length N such that exactly K indices in that permutation are good.

If no such permutation exists, output -1.

If multiple such permutations exist, output any.

------ Input Format ------

  • The first line contains a single integer T - the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains two integers N and K - the length of the permutation to be constructed and the number of good indices.

------ Output Format ------

For each test case, output any permutation satisfying the given condition.

------ Constraints ------

$1 ≤ T ≤ 1000$
$1 ≤ N ≤ 10^{5}$
$1 ≤ K ≤ N$
- Sum of $N$ over all testcases does not exceed $2 \cdot 10^{5}$

----- Sample Input 1 ------
2
1 1
6 2

----- Sample Output 1 ------
1
4 5 6 1 2 3

----- explanation 1 ------
Test case-1: In $[1]$, $P_{1} = 1$ is divisible by $1$. Therefore it is a valid permutation having $1$ good index.

Test case-2: In $[4, 5, 6, 1, 2, 3]$, $P_{1} = 4$ is divisible by $1$ and $P_{3} = 6$ is divisible by $3$. Therefore it is a valid permutation having $2$ good indices.

输入格式

见题面

输出格式

见题面

样例输入
2 1 1 6 2
样例输出
1 4 5 6 1 2 3