/**
* struct Point {
* int x;
* int y;
* };
*/
class Solution {
public:
/**
*
* @param points Point类vector
* @return int整型
*/
int gcb(int a,int b){
return b == 0 ? a : gcb(b, a % b);
}
int maxPoints(vector<Point>& points) {
int len = points.size();
if(len < 2) return len;
int res = 0;
for(int i = 0;i < len;i++){
map<pair<int,int>,int> recordMap;
int dup = 1;
for(int j = i + 1;j < len;j++){
int delta_x = points[i].x - points[j].x;
int delta_y = points[i].y - points[j].y;
if(delta_x == 0 && delta_y == 0){
dup++;
}else{
int g = gcb(delta_x,delta_y);
delta_x = delta_x / g;
delta_y = delta_y / g;
recordMap[{delta_x,delta_y}]++;
}
}
res = max(res,dup);
for(auto it=recordMap.begin();it != recordMap.end();it++){
res = max(res,dup + it->second);
}
}
return res;
}
};