Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from math import gcd
- file_in = "input.txt"
- file_out = "output.txt"
- sys.stdin = open(file_in, 'r')
- sys.stdout = open(file_out, 'w')
- n = int(input())
- points = []
- max_points = 1
- for i in range(n):
- x, y = map(int, input().split())
- points.append((x, y))
- for i in range(n-1):
- slopes = {}
- tmp_max = 1
- x1, y1 = points[i]
- for j in range(i+1, n):
- x2, y2 = points[j]
- dx, dy = x2 - x1, y2 - y1
- _gcd = gcd(dx, dy)
- dx //= _gcd
- dy //= _gcd
- if dx < 0:
- dx = -dx
- dy = -dy
- elif dx == 0 and dy < 0:
- dy = -dy
- if not slopes.get((dx, dy)):
- slopes[(dx, dy)] = 1
- slopes[(dx, dy)] += 1
- tmp_max = max(tmp_max, slopes[(dx, dy)])
- max_points = max(tmp_max, max_points)
- print(max_points)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement