Formula for winning CB scholarship (Java)

Hi,
Is there a reason we can’t use a formula in this question?
Suppose i is the number of students winning a scholarship that means (N-i) is the students losing. i.e.
i*X = (N-i)*Y+M
Solving this equation I get the answer in one line and it’s passing all the test cases. Is there a situation where it would fail?

@Anshul-Chauhan-10221922864290257 since you have solved the equation directly, it will not fail test cases. (in any case, the test cases usually cover all the corner cases)