You are given a quadratic function ‘Ax2 + Bx + C’ and a sorted array of 'N' integers ‘ARR’. Along with this, you are also provided with the integers ‘A’, ‘B’, and ‘C’.
Your task is to apply the given quadratic equation to each input in ‘ARR’ and return the sorted list of the outputs.
Note:
‘A’, ‘B’ and ‘C’ can be equal to 0.
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case contains three space-separated integers ‘A’, ‘B’, and ‘C’ representing the coefficients of the quadratic equation.
The second line of each test case will contain a single integer ‘N’ which denotes the size of the ‘ARR’.
The third line of each test case will contain ‘N’ space-separated integers, representing the elements of ‘ARR’.
Output Format:
For each test case, return all the outputs in non-decreasing order.
Output for every test case will be printed in a separate line.
Note:
You don’t need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 10^5
-10^5 <= A, B, C < =10^5
-10^5 <= ARR[ i ] <= 10^5
Time limit: 1 sec
2
1 2 -3
4
-3 -1 0 1
0 5 -3
5
-2 -1 0 1 2
-4 -3 0 0
-13 -8 -3 2 7
In the first test case,

This figure shows all the inputs and their corresponding output.
For the second test case, it is a line with a positive slope. So the output will increase as the input increases.
2
0 0 11
6
-100 -88 66 68 100 211
1 0 0
5
-3 -2 0 2 3
11 11 11 11 11 11
0 4 4 9 9
For the first test case, the given equation is a constant function y = 11. So the output will be the same for all the inputs.
Can you find the solution after calculating the value of the quadratic function for each element?
We will create a helper function, to evaluate the value of the equation for a given input.
long long QUADRATIC_EVALUATION(long long a, long long b, long long c, long long x)
It takes coefficients and the current element of ‘ARR’ as the input and returns the correspondent output.
We will go through all the inputs and store their ’QUADRATIC_EVALUATION’ in an array and then sort the array.
The steps are as follows:
O(N* log(N)), where ‘N’ is the size of the ‘ARR’.
We will iterate through each element of ‘ARR’ once and compute their ’quadraticEvaluation’ and then sort all the outputs in non-decreasing order. So, the overall time complexity will be O(N * log(N)).
O(N), where ‘N’ is the size of the ‘ARR’.
The space required to store all the output values will be O(N), So the overall space complexity will be O(N).