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

×

BITMASK4 - Editorial

Problem Link:

Contest
Practice

Difficulty:

Medium

Problem:

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

Explanation:

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.

Solution:

Author's solution can be found here.

asked 13 May '17, 19:27

hsagarthegr8's gravatar image

2★hsagarthegr8
163
accept rate: 0%

edited 29 May '17, 14:15

admin's gravatar image

0★admin ♦♦
19.7k350498541


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 ??

link

answered 30 May '17, 16:56

am10's gravatar image

4★am10
556
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×2,575
×637
×160
×61
×1

question asked: 13 May '17, 19:27

question was seen: 619 times

last updated: 01 Jun '17, 17:53