How do I find integer solutions for the following inequality

231 Views Asked by At

I have to write an algorithm to find all integer solutions to inequalities of the form $ax^2+by\leq c$, for example $-x^2+3y<7$, with constraints on x and y like $15\leq x\leq 31$ and $63\leq y\leq 92$.

A possible way is to loop over all x, calculate y and verify if it's integer, but is there any other way.

1

There are 1 best solutions below

4
On

Find where equality holds in $ax^2+bx \le c$ by solving $ax^2+bx - c=0$.

By looking at the shape of the curve, decide whether the inequality holds between or outside the roots.

Combine this with the other constraints on $x$ and then use the fact that you are looking for integers.