/*
表示很无语,为什么同样的点还要计算在里面,导致一直没有AC
*/
/**
* Definition for a point.
* struct Point {
* int x;
* int y;
* Point() : x(0), y(0) {}
* Point(int a, int b) : x(a), y(b) {}
* };
*/
class Solution {
public:
int maxPoints(vector<Point> &points) {
int len = points.size();
if(len <= 2) return len;
int ans = 2;
for(int i = 0 ; i < len ; i ++){
int du = 0;
for(int j = i + 1 ; j < len ; j ++){
int cnt = 1;
if(points[j].x == points[i].x && points[j].y == points[i].y){
du ++;
ans = max(cnt+du , ans);
continue;
}
cnt ++;
for(int k = j + 1 ; k < len ; k ++){
int x = (points[k].x - points[i].x)*(points[k].y - points[j].y);
int y = (points[k].x - points[j].x)*(points[k].y - points[i].y);
if(x == y) cnt ++;
}
ans = max(cnt+du , ans);
}
}
return ans;
}
};