You are viewing a single comment's thread. Return to all comments →
you can use while loop.it is much more effective than 10000 iterations.. OR you can loop until x1 is greater than x2.
if(v2>=v1) { cout<<"NO"; } else { while(x1<=x2) { x1+=v1; x2+=v2; if(x1==x2) {cout<<"YES"; flag=1;} } if(flag==0) cout<<"NO"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Number Line Jumps
You are viewing a single comment's thread. Return to all comments →
you can use while loop.it is much more effective than 10000 iterations.. OR you can loop until x1 is greater than x2.