300525: CF100F. Polynom
Memory Limit:64 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
F. Polynomtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output
You are given a polynom in form p(x) = (x + a1)·(x + a2)·... (x + an). Write Pike program to print it in a standard form p(x) = xn + b1xn - 1 + ... + bn - 1x + bn. You should write each addend in form «C*X^K» (for example, 5*X^8).
Please, write the polynom in the shortest way, so you should skip unnecessary terms: some terms «C*X^K» should be reduced or even omitted. Look for the samples for clarification.
InputThe first line of the input contains n (1 ≤ n ≤ 9). The following n lines contain integer ai ( - 10 ≤ ai ≤ 10).
OutputPrint the given polynom in a standard way. Note, that the answer in this problem response uniquely determined.
ExamplesInput2Output
-1
1
X^2-1Input
2Output
1
1
X^2+2*X+1