The testcase you’re stuck with might be this
1
3 3 2
From what i understand, we just need to verify 3 things,
If area the rectangle is already smaller than or equal to the square, no need to make any change.
If reducing either side of the rectangle to 1 can satisfy the condition. This will ensure only 1 change satisfies codition.
if none of the above cases fulfill the ask, we must have to perform more than 1 change.
LOGIC:
if (A * B <= X * X) {
System.out.println(0);
} else if (A <= X || B <= X || (1 * B <= X * X) || (A * 1 <= X * X)) {
System.out.println(1);
} else {
System.out.println(2);
}