2019牛客暑期多校训练营(第七场)Irreducible Polynomial (数学)

链接: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();
    }
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值