• + 0 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";
        }