当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4447:Yuanfang, What Do You Think?

题目描述
Factoring a polynomial is always a hard and important issue in mathematics teaching in middle schools. Teacher Liu loves teaching this issue very much, but his students are not good at it.
Yuanfang is the best student in Teacher Liu's class. Every time when Teacher Liu comes up with a hard problem and it seems no student can solve it, Liu always says: "Yuanfang , what do you think?"。
This week, Teacher Liu began to teach how to factor a polynomial. On Monday, Teacher Liu said : "Let's factor x2-1 ... Yuanfang, what do you think?"
On Tuesday, Teacher Liu said : "Let's factor x3-1 ... Yuanfang, what do you think?"
On Wednesday, Teacher Liu said : "Let's factor x4-1 ... Yuanfang, what do you think?"
…..
On Friday, Yuanfang got crazy. She wanted to solve this problem permanently. So she came to you, the only programmer she knows, for help.
You should write a program to factor the polynomial xn-1. In other words, represent the polynomial xn-1 by a product of irreducible polynomials in which coefficients are all integers.
输入解释
There are several test cases. Every case is an integer n in a line (n≤1100) meaning that you should factor the polynomial xn-1.
Input ends with n=0.
输出解释
We print polynomials like this:
1.x2 to x^2;
2.x3-1 to x^3-1;
3.x6-2x4+1 to x^6-2x^4+1.
For each test case, you should print the result polynomials in a certain order. To sort the polynomials, we compare the coefficients of them from high-degree to low-degree. The coefficient with a smaller absolute value has a smaller order. When absolute values are the same, negative coefficient has a smaller order. Please print the result polynomials from small order to large order.
In the result, put every factor polynomial between a pair of parentheses(Except that the result is just x-1 as shown in sample). Every factor polynomial must satisfy the following conditions:
1.It can't be factored any more.
2.All the terms of the same degree must be combined.
3.No term's coefficient is 0.
4.The terms appear in the descending order by degree.
5.All coefficients are integers.
输入样例
1
2
3
4
5
6
0
输出样例
x-1
(x-1)(x+1)
(x-1)(x^2+x+1)
(x-1)(x+1)(x^2+1)
(x-1)(x^4+x^3+x^2+x+1)
(x-1)(x+1)(x^2-x+1)(x^2+x+1)
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4447

最后修改于 2020-10-25T23:13:36+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)