GUPTA MECHANICAL

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

Wednesday, 8 June 2022

[Solution] Construct An Array CodeChef Solution | CodeChef Problem Solution 2022

Given an integer N, construct an array A of length N such that:

  • 1Ai1018 for all (1iN);
  • There exists a subsequence of length greater than 1 such that the gcd of all elements of the subsequence is i, for all 1iN.
    More formally, for all (1iN), there exists a subsequence S of array A such that the length of the subsequence is k(2kN) and gcd(S1,S2,,Sk)=i.

It can be proven that it is always possible to construct such 

Solution Click Below:-  CLICK HERE


A under given constraints. If there exist multiple such arrays, print any.

Input Format

  • The first line of input contains a single integer T, denoting the number of test cases. The 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, denoting the elements of the array A. The ith of these N integers is the ith element of the array A.

If there exist multiple such arrays, print any.

Constraints

  • 1T103
  • 3N103
  • Sum of N over all test cases does not exceed 

No comments:

Post a Comment