#P2312. Finding Integer Solutions for a Polynomial Equation
Finding Integer Solutions for a Polynomial Equation
Finding Integer Solutions for a Polynomial Equation
You are given a polynomial equation in the form:
\(a_0 + a_1 x + a_2 x^2 + \cdots + a_n x^n = 0\)
and two positive integers \(n\) (the degree of the polynomial) and \(m\) where \(m\) defines the interval \([1, m]\). Your task is to find all integer solutions \(x\) within the interval \([1, m]\) such that the polynomial evaluates to zero.
If there is no integer solution within the range, output NO SOLUTION.
inputFormat
The first line contains two positive integers \(n\) and \(m\), where \(n\) is the degree of the polynomial, and \(m\) defines the interval \([1, m]\) to search for solutions.
The second line contains \(n+1\) integers representing the coefficients \(a_0, a_1, \ldots, a_n\) of the polynomial.
outputFormat
Output all integer values \(x\) (separated by a space) in ascending order that satisfy the equation. If no such integer exists within \([1, m]\), output NO SOLUTION.
sample
2 10
1 -3 2
1