An integer polynomial of degree **n** is a function of the form a_{0} + a_{1}x^{1} + a_{2}x^{2} + ... + a_{n}x^{n}, where each a_{i} is a constant integer and x is a variable. An *integer root* of an integer polynomial is an integer value of x for which the expression equals zero.
You will be given the coefficients of an integer polynomial, and must return all the integer roots in increasing order. Roots must appear only once in the output (see example 1 for clarification).
Since the degree may be quite large, the coefficients are presented indirectly. Use the following pseudo-code to generate the coefficients a[0] to a[**n**]:
lX = length(**X**)
lY = length(**Y**)
for i = 0, 1, ..., n:
p = i mod lX
q = (i + **Y**[i mod lY]) mod lX
a[i] = **X**[p]
**X**[p] = **X**[q]
**X**[q] = a[i]
The array indices are all 0-based and `a mod b` is the remainder when a is divided by b. |