HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Object Oriented Programming > problem:


170. 50327 - Parallel Lines

Guest
• Review clarifications (2)

Volume problems

• 50346 - The Biggest Date
• 50992 - Top K Obese Classes
• 50991 - Intersecting Circles
• 50989 - Rectangles and Points
• 50984 - Top m hardworking employees
• 50269 - Matrix Determinant
• 50986 - The Oldest Person
• 130. 50326 - Matrix Operations
• 170. 50327 - Parallel Lines
• 180. 50325 - How much time passed?

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

Parallel Lines

Mr. Erind, school math teacher, has a list of lines in a file and he wants to see the number of parallel lines.

Two line segments are said to be parallel if their slopes are equal. The slope of a line can be calculated with the following formula:
                (y2-y1)
    slope = m = -------
                (x2-x1)

Note: Pay attention to the condition when x1==x2, the program cannot calculate the slope because it will give division by zero error.

Question:
Write a program that is going to get x and y coordinates of a line segment. And then, the program will compare that line to the other line segments. At the end, the program is going to show the number of parallel lines with the first line segment.

Input specification
First, you will be given the x y coordinates of the first line segment (x1, y1, x2, y2) where x1 and y1 are the coordinates of the start point and x2, y2 are the coordinates of the end point of the first line segment. Then, you will be given a number (n), the number of following line segments. The following n lines will have four integers each (x1, y1, x2, y2) where x, y coordinates are integers between -10000 and 10000 and 1 < n ≤ 5000

Output specification
Show the number of parallel line segments with the first line segment

Sample Input I
  1 1 2 2
  4
  4 5 4 6
  3 3 5 5
  4 4 2 2
  1 5 2 9
Sample Output I
  2

Output Explanation :
  Only the line segments, (3 3 5 5) and (4 4 2 2) are parallel to (1 1 2 2).


Для отправки решений необходимо выполнить вход.

www.contester.ru