Factoring a Polynomial
Time limit1sMemory limit512 MB
Given a polynomial with integer coefficients of degree at most 20, decide whether it is irreducible over the reals.
- Level
Easy3 of 10
- Topics
- Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
A polynomial in one variable can be written as the formal sum , where is the formal variable and the numbers are its coefficients. The largest index with is called the degree of the polynomial; if for every , the degree is defined to be . A polynomial whose degree is or is called trivial; any other polynomial is non-trivial.
A polynomial with real coefficients is called irreducible if it cannot be written as a product of two or more non-trivial polynomials with real coefficients; otherwise it is called reducible. For instance, is reducible because , whereas is irreducible. It is a classical fact that every polynomial can be written as a product of one or more irreducible polynomials.
Given a polynomial with integer coefficients, determine whether it is irreducible over the real numbers.
Input
The first line contains the degree of the polynomial ().
The second line contains integers — the coefficients of the polynomial (, ).
Output
Print YES if the polynomial is irreducible over the real numbers, and NO otherwise.