GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday 10 June 2022

[Solution] Divisible by i CodeChef Solution | CodeChef Problem Solution 2022

You are given an integer N.

Construct a permutation P of length N such that

  • For all i (1iN1)i divides abs(Pi+1Pi).

Recall that a permutation of length N is an array where every integer from 1 to N occurs exactly once.

It can be proven that for the given constraints at least one such P always exists.

Input Format

  • The first line of input contains a single integer T, denoting the number of test cases. The

Solution Click Below:-  CLICK HERE



    •  description of T test cases follow.
    • The only line of each test case contains an integer N - the length of the array to be constructed.

    Output Format

    For each test case, output a single line containing N space-separated integers P1,P2,,PN, denoting the elements of the array P.









    If there exist multiple such arrays, print any.

    Constraints

    • 1T5104
    • 2N105
    • The sum of N over all test cases does not exceed 

    No comments:

    Post a Comment