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

B Irreducible Polynomial

Problem

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 + 7x .
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 x^2-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). T 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

输出描述:

For each test case, output “Yes” if it is irreducible, otherwise “No”.

示例1

输入

2
2
1 -2 1
2
1 0 1

输出

No
Yes

题意

判断一个多项式在实数范围内能否被因式分解

分析

在这里插入图片描述

代码

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int t;scanf("%d",&t);
    while(t--)
    {
        int a[25];
        int n;
        scanf("%d",&n);
        for(int i=0;i<n+1;i++) scanf("%d",&a[i]);
        if(n>2) cout<<"No"<<endl;
        else if(n==1) cout<<"Yes"<<endl;
        else {
            int k=a[1]*a[1]-4*a[0]*a[2];
            if(k<0) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
 }
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值