Irreducible Polynomial(数学)
Irreducible Polynomial
题目描述
In mathematics, a polynomial is an expression consisting of variables (also called indeterminate) and coefficients, that involves only the operations of addition, subtraction, multiplication, and non-negative integer exponents of variables. For example, x2 + 4x + 7.
A polynomial is said to be irreducible if it cannot be factored into two or more non-trivial polynomials with real coefficients.
For example, x2+1 is irreducible, but x2-2x+1 is not (since x2-2x+1=(x-1)(x-1)).Given a polynomial of degree with integer coefficients: anxn+an−1xn−1+…+a1x+a0, you need to check whether it is irreducible or not.
输入
The first line of the input gives the number of test cases, T (T≤100). test cases follow.
For each test case, the first line contains one integers n (0≤n≤20). Next line contains n + 1 integer numbers:
an,an−1,…,a1,a0
−109≤ai≤109
an≠0输出
For each test case, output “Yes” if it is irreducible, otherwise “No”.
样例输入
2 2 1 -2 1 2 1 0 1样例输出
No Yes
小知识点:
n表示最高次幂,当n>=3时,都可约,当n==2时,判断b^2-4ac,若大于0,可约,否则不可约,n<2时,肯定都不能约
代码:
#include
#include
#include
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
