• [deleted]
    + 0 comments

    it's basically a problem to check if two different arithmetic progressions have a same term at some n.

    let a1 = x1 and d1 = v1 and a2 = x2 and d2 = v2
    now
    => a1 + (n - 1) d1 = a2 + (n - 1) d2
    => a1 + a2 = (n - 1) (d2 - d1)
    => (a1 + a2) / (d2 - d1) = n - 1
    => n = 1 + (a1 + a2) / (d2 - d1)  
    // ensure (d2 - d1) = 1 if it is zero, to avoid error
    
    if n > 0 then YES otherwise NO