RGPC '17 P3 - Intercept
View as PDFIn today's math class, you learned how to find the equation of a polynomial function given its graph, but your friend Nemo did not, since he slept through the entire lesson. Needless to say, Nemo's act did not go unnoticed, and resulted in him being punished with extra homework questions to complete. Knowing that he won't have time to finish all of them, Nemo asks you, the best CS student in the school, to help him out.
Nemo is given  extra questions, where each question gives him the x-intercepts (roots) of the polynomial function, as well as a pair of coordinates in the form 
, representing a point that lies on the function's graph. Can you determine what the coefficients of the equation are in standard form 
 for each question?
Note: all input and coefficients are guaranteed to fit in signed 64-bit integral variables (e.g. long long in C++).
Input Specification
The first line of input will contain the integer  
. For each of the 
 questions, there will be 3 lines:
- The integer 
, representing the degree of the polynomial function.
 space-separated integers
, representing the x-coordinates of the roots of the function.
- Two space-separated integers 
and
, representing the coordinates of the known point.
 
Output Specification
Output a single line for each of the  questions, containing 
 space-separated integers representing the coefficients of the function in standard form from the 
 term to the 
 term.
Sample Input
2
2
3 4
0 12
3
-2 3 4
0 48
Sample Output
1 -7 12
2 -10 -4 48
Comments