#P4506. [CTSC2013] 因式分解
[CTSC2013] 因式分解
Description
By the Fundamental Theorem of Algebra, counting multiplicity, a degree polynomial over the complex numbers has exactly zeros (points where the function value is ). You are given an integer-coefficient polynomial whose zeros are all rational numbers (i.e., can be written as a ratio of two integers). If we deduplicate all nonzero zeros (the variable is not while the function value is ), we obtain distinct nonzero zeros, where the -th nonzero zero can be written as:
Here denotes the sign of the -th zero, and and are two coprime positive integers.
You are given . Output its factorized form.
Input Format
The input contains exactly one line: the polynomial .
The polynomial is always given in the following form:
The terms are in descending degree. Each is an integer. If , that term is omitted. If is negative, the preceding plus sign is omitted. If and , the is not printed. It is guaranteed that . See the sample input.
Output Format
Output one line: the factorized form in the following format: $a_n (x + u_1 / v_1)^{t_1} (x + u_2 / v_2)^{t_2} \cdots (x + u_s / v_s)^{t_s}$
Here and are coprime, and is a positive integer.
are sorted from largest to smallest. If , that factor is . If is negative, the plus sign is omitted. If , then is omitted.
If , the exponent is omitted.
If , the is omitted. See the sample output.
8x^7-258x^5+2112x^3-512x
8(x-4)^2(x-1/2)x(x+1/2)(x+4)^2
-x^2+2x-1
-(x-1)^2
Hint
| 测试点编号 | 多项式最高次数 | 互异零点数 | 系数范围(绝对值) |
|---|---|---|---|
satisfy:
$$\prod_{i=1}^r p_i \le 10^6, \prod_{i=1}^r q_i \le 10^6.$$Translated by ChatGPT 5
京公网安备 11011102002149号