Sort the given array after applying the given equation
Submissions: 6064   Accuracy:


  Difficulty: Easy   Marks: 2

Given a sorted integer array of size N, and 3 integers AB and C. The task is to find and print a new array in sorted order(increasing) where

The first line of input contains T denoting the number of test cases.The first line of each test case contains three integers A, B, and C, as described above. The second line of each test case contains a single integer N, the size of the input array. The third line of each test case contains N-space separated integers, denoting the array.

For each test case output, a single line containing N-space separated integers, the elements of the new array in sorted order.

1<= T <= 1000
-105<= A,B,C <= 105
-105<= Ai <= 105


-1 2 -1
-1 0 1 2 3 4
-9 -4 -4 -1 -1 0

After sorting, we get {-9, -4, -4, -1, -1, 0}
After applying the equation A*x*x + B*x + C on every element x we get, {-4,-1, 0, -1, -4, -9}
Input array is {-1, 0, 1, 2, 3, 4}.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Tanuj Yadav
Author: tanujyadav97

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.