[Solution] Easy Permutation solution codechef

Table of Contents

Easy Permutation solution codechef

Easy Permutation solution codechef – You are given an integer N.

Construct any permutation A of N integers such that the value LCM(1 + A_1 , 2 + A_2, \ldots, N + A_N) is minimised.

Note:

  • LCM denotes the least common multiple of the integers.
  • A permutation of N integers contains all integers from 1 to N exactly once.

Easy Permutation solution codechef

  • First line will contain T, number of test cases. Then the test cases follow.
  • Each test case contains a single line of input, one integer N.

Output Format

For each test case, output a permutation that minimises the value LCM(1 + A_1 , 2 + A_2, \ldots, N + A_N).

Constraints

  • 1 \leq T \leq 1000
  • 2 \leq N \leq 1000

Easy Permutation solution codechef

Input

Output

1
2
2 1 

Easy Permutation solution codechef

Test case 1: The permutation for which the value is minimised is [2, 1]. The minimum value is LCM(1+2, 2+1) = LCM(3, 3) = 3.

For Solution

“Click Here”

Leave a Comment