← 返回 microsoft 的题目列表Max Points on a Line
类型:online_judge
Given a set of points on a 2D plane where points[i] = [xi, yi], return the maximum number of points that lie on the same straight line.
Requirements:
Correctly handle duplicate points, vertical lines (infinite slope), and reduced slope representation (avoid floating-point errors).
Constraints: 1 <= n <= 300, -10^4 <= xi, yi <= 10^4.
I/O format (stdin/stdout):
Input: first line n; then n lines each containing two integers x y.
Output: one integer: the maximum number of collinear points.
Example: Input:
3
1 1
2 2
3 3
Output:
3
Example
Input
3
1 1
2 2
3 3
Output
3