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

建议使用的浏览器:

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

2126:Factoring a Polynomial

题目描述
Recently Georgie has learned about polynomials. A polynomial in one variable can be viewed as a formal sum anxn + an-1xn-1 + . . . + a1x + a0 , where x is the formal variable and a i are the coefficients of the polynomial. The greatest i such that ai != 0 is called the degree of the polynomial. If ai = 0 for all i, the degree of the polynomial is considered to be -∞. If the degree of the polynomial is zero or -∞, it is called trivial, otherwise it is called non-trivial.
What really impressed Georgie while studying polynomials was the fact that in some cases one can apply different algorithms and techniques developed for integer numbers to polynomials. For example, given two polynomials, one may sum them up, multiply them, or even divide one of them by the other.
The most interesting property of polynomials, at Georgie's point of view, was the fact that a polynomial, just like an integer number, can be factorized. We say that the polynomial is irreducible if it cannot be represented as the product of two or more non-trivial polynomials with real coefficients. Otherwise the polynomial is called reducible. For example, the polynomial x2 - 2x + 1 is reducible because it can be represented as (x - 1)(x - 1), while the polynomial x2 + 1 is not. It is well known that any polynomial can be represented as the product of one or more irreducible polynomials.
Given a polynomial with integer coefficients, Georgie would like to know whether it is irreducible. Of course, he would also like to know its factorization, but such problem seems to be too difficult for him now, so he just wants to know about reducibility.
输入解释
The first line of the input contains n --- the degree of the polynomial (0 <= n <= 20). Next line contains n + 1 integer numbers, an , an-1 , . . . , a1 , a0 --- polynomial coefficients (-1000 <= ai <= 1000, an != 0).
输出解释
Output YES if the polynomial given in the input file is irreducible and NO in the other case.
输入样例
2 
1 -2 1 
输出样例
NO

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2126

最后修改于 2020-10-29T06:24:03+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536