Unable to understand the question


As 0 is neither positive or negative. The least possible value we can assume would be Z = 1.
and let’s substitute the same.
As for example
A = 2 & B = 3

Z= PA + QB

1-PA= QB

and for any given inputs of A & B, we can always find a Q & P as integers for the derived equation. So for any input, the minimum value will always be 1.

Or did I miss anything ?


p q are integers


Minimum difference cannot always be 1. it will be the gcd of two numbers. Try to check extended euclidean algorithm