https://www.codechef.com/CHIL2020/problems/MLINE

hello is this problem we use. y-mx-c --> to find out if pt(x1,y1) is to right , left of line

can anyone please explain the reason for this??(mathematical prof.) @ssrivastava990

If two points lies on opposite sides of a line. Then the line connecting them will always intersect the given line

1 Like

yes but here we have only one point per query

According to what i remember (12th maths) if we satisfy two points on the equation of line , and both points give opposite sign (±,-+) then they lie on opposite sides of line .

Similarly if both points give same sign(++,–) then they lie on same side of line.

Hence we need to count point on left (say p)and right side(say q) of the line (by satisfying the given point), and our answer would be p*q pairs.

Proof -https://doubleroot.in/lessons/straight-line/position-of-a-point-relative-to-a-line/

1 Like

thank you , I just wanted mathematical proof for this

Thanks bro, got my error