题意:给出一个实系数多项式,问是否可以分解。
分析:
实系数多项式因式分解定理 每个次数大于零的实系数多项式都可以在实数域上唯一地分解成一些一次或二次不可约因式的乘积。
所以对于大于2的情况一定可以分解。对于<=2的情况,判断其本身是否可约,一次一定不可约,二次用b^2-4ac判断是否有根,有则可约,否则不可约。
View Code
#include#include #include #include using namespace std; int main() { //freopen("t.txt", "r", stdin); int n; scanf("%d", &n); if (n <= 1) { printf("YES\n"); return 0; } if (n > 2) { printf("NO\n"); return 0; } int a, b, c; scanf("%d%d%d", &a, &b, &c); if (b * b - 4 * a * c >= 0) printf("NO\n"); else printf("YES\n"); return 0; }