9712621 | CodeChef (beginner question) help in mr.p dilemma

ICM2008 Problem - CodeChef - problem
https://www.codechef.com/viewsolution/33535903- my solution

the logic i used: i calculated relative distance using fabs(a-b) and relative speed using fabs(c-d)
the i checked whether distance%relative==0 or not
i also added special case where relative==0 to avoid divide by 0 error
note: for the case 10 20 3 7 , my codeblocks said β€œNO” (correct answer)
but online ide said β€œYES” ?? i am confused .
thank you for your help guys :smiley:

1 Like

Just check if (max(a,b)-min(a,b))%(max(c,d)-min(c,d))==0
print Yes
print No

But you also have to handle the case when a==b||c==d
Here is the solution: