RGPC '17 P3 - Intercept

View as PDF

Points: 7
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

In 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:

1. The integer , representing the degree of the polynomial function.
2. space-separated integers , representing the x-coordinates of the roots of the function.
3. 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