GUPTA MECHANICAL

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

Monday 8 August 2022

[Solution] Build Permutation Codeforces Solution




Build Permutation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

0-indexed array a of size n is called good if for all valid indices i (0in1), ai+i is a perfect square.

Given an integer n. Find a permutation p of [0,1,2,,n1] that is good or determine that no such permutation exists.

 An integer x is said to be a perfect square if there exists an integer y such that x=y2.

 An array b is a permutation of an array a if b consists of the elements of a in arbitrary order. For example, [4,2,3,4] is a permutation

Solution Click Below:-  👉CLICK HERE👈

👇👇👇👇👇

 occupied

 of [3,2,4,4] while [1,2,2] is not a permutation of [1,2,3].

Input

The first line contains a single integer t (1t104) — the number of test cases.

The only line of each test case contains a single integer n (1n105) — the length of the permutation p.

It is guaranteed that the sum of n over all test cases does not exceed 105.

Output

For each test case, output n distinct integers p0,p1,,pn1 (0pin1) — the permutation p — if the answer exists, and 1 otherwise.

No comments:

Post a Comment