Sumar and the Floating Rocks

  • + 0 comments

    Equation of Line (y-y1)=(y2-y1)/(x2-x1) (x-x1)

    => y(x2-x1) - y1 (x2-x1) = x (y2-y1) - x1 (y2-y1)

    => y(x2-x1) - x (y2-y1) = - x1 (y2-y1) + y1 (x2-x1)

    => - x (y2-y1) + y(x2-x1) = - x1 (y2-y1) + y1 (x2-x1)

    => a=(x2-x1), b=(y2-y1)

    as per the Extended Euclid Algorithm : for integral solution to this equation, the RHS should be multiple of gcd(a,b) i.e. gcd (|x2-x1| ,| y2-y1|)