链接:https://ac.nowcoder.com/acm/contest/887/B
来源:牛客网
题目描述
输入描述:
输出描述:
For each test case, output “Yes” if it is irreducible, otherwise “No”.
输入
2
2
1 -2 1
2
1 0 1
输出
No
Yes
Solution
一开始想到通过判断有没有根来判断是否可以因式分解,后来发现这样实在是大错特错,因为因式分解的各个部分可能也是没根的。。。
然而这是一个定理,实系数多项式因式分解定理,
数学归纳法证明
AC Code
public static void main(String[] args) throws Exception {
int t;
for (t = nextInt(); t-- != 0; ) {
int n = nextInt();
if (n < 2) {
out.println("Yes");
for (int i = 0; i <= n; ++i)
nextInt();
} else if (n > 2) {
out.println("No");
for (int i = 0; i <= n; ++i)
nextInt();
} else {
int a = nextInt();
int b = nextInt();
int c = nextInt();
if (b * b - 4 * a * c < 0)
out.println("Yes");
else
out.println("No");
}
}
out.flush();
}