
Each element of the sequence should be distinct.
The sequence should be of length 'N'.
Each element should have a value between 1 to 60000.
Let 'M' denote the sum of all the elements of the sequence and 'K' be the gcd of all the elements of the sequence then 'K' should be equal to 1 and for each element, 'A[i]' (0 <= i < 'N') gcd of 'A[i]' and 'M' should not be equal to 1.
Let 'N' = 3.
'A' = {2, 3, 63} satisfies all the conditions of the cool sequence.
The first line contains an integer 'T', which denotes the number of test cases.
For every test case:-
The first line contains only one integer 'N', denoting the number of elements of the cool sequence.
For each test case, Return 'N' space-separated integers denoting the elements of the cool sequence in any order.
You don’t need to print anything. Just implement the given function. 1 in the output denotes the correct sequence and 0 denotes the wrong sequence.
1 <= 'T' <= 10
1 <= 'N' <= 40000
Time Limit: 1 sec
Approach:-
Looking at the tight constraints we can observe that we actually need two-thirds of numbers between 1 and N. The main idea is that if we pick 'M' to be a multiple of some small primes 'X', then we just have to make sure that each element of the array is divisible by the 'X' and 'K' = 1. Based on the above idea we can choose 'M' = 6q, for some integer q and we will choose the elements of the cool sequence as multiples of 2 or 3 and we will definitely choose 2 and 3 to make sure that 'K' always remains 1. The constraints also hint towards this approach as there exist exactly two third numbers that are multiples of 2 or 3 between 1 and N. After taking all the numbers of the sequence as multiples of 2 or 3, it might be possible that the sum is not divisible by 6. The sum can be of the form 6q+2, 6q+3, 6q+5, 6q.
We can handle each case separately.
The above approach only works for numbers for 'N' > 5. For 'N' = 3, 4, 5 we can take {2, 3, 63}, {2, 3, 9 10}, and {2, 3, 6, 9, 10} respectively.
Algorithm:-