• + 0 comments

    Yes there are a number of conditions to check:

    int num = x2 - x1;
    int den = v1 - v2;
    if (den == 0) cout << "NO";
    else if (num % den != 0) cout << "NO";
    else if (num > 0 && den < 0) cout << "NO";
    else cout << "YES";
    

    If x1 < x2 would not be stated, there are just two more conditions to check:

    if (num == 0) cout << "YES";
    else if (den == 0) cout << "NO";
    else if (num % den != 0) cout << "NO";
    else if (num < 0 && den > 0) cout << "NO";
    else if (num > 0 && den < 0) cout << "NO";
    else cout << "YES";