Partial Fraction Decomposition

Time Limit: 2 Seconds
Memory Limit: 65536 KB

It is easy to obtain (6x^{2}-5x-5)/(x^{3}-2x^{2}-x+2) from 1/(x+1) + 2/(x-1) + 3/(x-2). But how about the other way around?

Given a rational function in the form (a_{2}x^{2}+a_{1}x+a_{0})/(x^{3}+b_{2}x^{2}+b_{1}x+b_{0}) where a_{i} and b_{i} are integers for i = 0, 1, 2. If the denominator factors as (x-r_{1})(x-r_{2})(x-r_{3}) where r_{i}'s are distinct integers, then these will be the denominators of the partial fraction decomposition. We are looking for a decomposition of the rational function such that

A_{1}/(x-r_{1}) + A_{2}/(x-r_{2}) + A_{3}/(x-r_{3}) = (a_{2}x^{2}+a_{1}x+a_{0})/(x^{3}+b_{2}x^{2}+b_{1}x+b_{0})
**Input**
The input consists of several test cases, each occupying a line with 6 integers in the format:

a_{0} a_{1} a_{2} b_{0} b_{1} b_{2}

A case with a_{0}=a_{1}=a_{2}=0 signals the end of input and must not be processed.

**Output**

For each test case, print in one line the 6 numbers in the format:

r_{1} r_{2} r_{3} A_{1} A_{2} A_{3}

Note: It is guaranteed that the decomposition exists for each case, because I obtained the input from output ^_^. It is also guaranteed that r_{i}'s are distinct integers and you must output them in increasing order. However, it is NOT guaranteed that A_{i}'s are integers, and you must output them accurate up to 2 decimal places.

**Sample Input**

-5 -5 6 2 -1 -2
-5 -3 5 2 -1 -2
0 0 0 1 2 3

**Sample Output**
-1 1 2 1.00 2.00 3.00
-1 1 2 0.50 1.50 3.00

Author:

**CHEN, Yue**
Source:

**Zhejiang University Local Contest 2005**
Submit
Status