Football Season

I did not understand the explanation which was given to prove that the value of y calculated after taking mod is minimum possible. Please explain.
Also I didn’t understand codeforces Editorial .Plz Help!!

g is the largest common divisor of w and d, and we divide p by it. So obviously we will get the smallest value of y from the equation.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

@sarthak goel
As y = ( (p/g)%(w/g) ) / ( (d/g)%(w/g) );
here g is present both in denominator and numerator , then how we can say it is minimum???

May you please elaborate little a bit more!