Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import sys
  2. from math import gcd
  3.  
  4. file_in = "input.txt"
  5. file_out = "output.txt"
  6. sys.stdin = open(file_in, 'r')
  7. sys.stdout = open(file_out, 'w')
  8. n = int(input())
  9. points = []
  10. max_points = 1
  11. for i in range(n):
  12. x, y = map(int, input().split())
  13. points.append((x, y))
  14. for i in range(n-1):
  15. slopes = {}
  16. tmp_max = 1
  17. x1, y1 = points[i]
  18. for j in range(i+1, n):
  19. x2, y2 = points[j]
  20. dx, dy = x2 - x1, y2 - y1
  21. _gcd = gcd(dx, dy)
  22. dx //= _gcd
  23. dy //= _gcd
  24. if dx < 0:
  25. dx = -dx
  26. dy = -dy
  27. elif dx == 0 and dy < 0:
  28. dy = -dy
  29. if not slopes.get((dx, dy)):
  30. slopes[(dx, dy)] = 1
  31. slopes[(dx, dy)] += 1
  32. tmp_max = max(tmp_max, slopes[(dx, dy)])
  33. max_points = max(tmp_max, max_points)
  34. print(max_points)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement