|
<p> |
|
Consider an N-degree polynomial, expressed as follows: |
|
</p> |
|
|
|
<p> |
|
<b>P</b><sub>N</sub> * x<sup>N</sup> + <b>P</b><sub>N-1</sub> * x<sup>N-1</sup> + ... + <b>P</b><sub>1</sub> * x<sup>1</sup> + <b>P</b><sub>0</sub> * x<sup>0</sup> |
|
</p> |
|
|
|
<p> |
|
You'd like to find all of the polynomial's x-intercepts — in other words, all distinct real values of x for which the expression evaluates to 0. |
|
</p> |
|
|
|
<p> |
|
Unfortunately, the order of operations has been reversed: |
|
Addition (<strong>+</strong>) now has the highest precedence, followed by multiplication (<strong>*</strong>), followed by exponentiation (<strong>^</strong>). |
|
In other words, an expression like a<sup>b</sup> + c * d should be evaluated as a<sup>((b+c)*d)</sup>. |
|
For our purposes, exponentiation is right-associative (in other words, a<sup>b<sup>c</sup></sup> = a<sup>(b<sup>c</sup>)</sup>), |
|
and 0<sup>0</sup> = 1. |
|
The unary negation operator still has the highest precedence, so the expression -2<sup>-3</sup> * -1 + -2 evaluates to -2<sup>(-3 * (-1 + -2))</sup> = -2<sup>9</sup> = -512. |
|
</p> |
|
|
|
<h3>Input</h3> |
|
|
|
<p> |
|
Input begins with an integer <strong>T</strong>, the number of polynomials. |
|
For each polynomial, there is first a line containing the integer <strong>N</strong>, the degree of the polynomial. |
|
Then, <strong>N</strong>+1 lines follow. The <em>i</em>th of these lines contains the integer <strong>P<sub>i-1</sub></strong>. |
|
</p> |
|
|
|
<h3>Output</h3> |
|
|
|
<p> |
|
For the <em>i</em>th polynomial, print a line containing "Case #<em>i</em>: <strong>K</strong>", |
|
where <strong>K</strong> is the number of distinct real values of <strong>x</strong> for which the polynomial evaluates to 0. |
|
Then print <strong>K</strong> lines, each containing such a value of <strong>x</strong>, in increasing order. |
|
</p> |
|
|
|
<p> |
|
Absolute and relative errors of up to 10<sup>-6</sup> will be ignored in the x-intercepts you output. However, <strong>K</strong> must be exactly correct. |
|
</p> |
|
|
|
|
|
<h3>Constraints</h3> |
|
|
|
<p> |
|
1 ≤ <strong>T</strong> ≤ 200 <br /> |
|
0 ≤ <strong>N</strong> ≤ 50 <br /> |
|
-50 ≤ <strong>P<sub>i</sub></strong> ≤ 50 <br /> |
|
<strong>P<sub>N</sub></strong> ≠ 0 <br /> |
|
</p> |
|
|
|
|
|
<h3>Explanation of Sample</h3> |
|
|
|
<p> |
|
In the first case, the polynomial is 1 * x<sup>1</sup> + 1 * x<sup>0</sup>. With the order of operations reversed, this is evaluated as (1 * x)<sup>(((1 + 1) * x)<sup>0</sup>)</sup>, which is equal to 0 only when x = 0. |
|
</p> |
|
|
|
<p> |
|
In the second case, the polynomial does not evaluate to 0 for any real value x. |
|
</p> |
|
|