You are not logged in. Please login at to post your questions!


BITMASK4 - Editorial

Problem Link:





We need to find the biggest set of parallel lines from the given lines.


Equation of line is given by $ ax+by+c=0$ -eq(1).
where a,b,c are coefficients.
And the slope-intercept form of the line is given by $y = mx + C$ -eq(2).
where m is the slope of line and C is the y-intercept.
Comparing eq(1) and eq(2), we get:
$ m = -a/b$ and $C = -c/b$

Now for two lines to be parallel, they must have the same slope and different y-intercept. Different y-intercept because if two lines have same slope and y-intercept then both lines are same and they will meet at every point.
So we just need to make different sets of parallel lines according to their slopes and then find the length of the largest set.
Also, we need to check for the case where b is 0. To handle the divide by zero exception. In that case, we can assign m to a very large number and C to -c/a.
One way to do this is to use a map of slope and set of lines having that slope. The slope with the largest set of lines will be the required answer.


Author's solution can be found here.

asked 13 May '17, 19:27

hsagarthegr8's gravatar image

accept rate: 0%

edited 29 May '17, 14:15

admin's gravatar image

0★admin ♦♦

In this problem why we are not having Precision error due to floating point arithmetic .As in your solution you are taking m = -a/b and y intercept = -c/a.can you explain ??


answered 30 May '17, 16:56

am10's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 13 May '17, 19:27

question was seen: 619 times

last updated: 01 Jun '17, 17:53