inlineintgcd(int a, int b) { while (b != 0) { int temp = a % b; a = b; b = temp; } return a; } intmaxPoints(vector<vector<int>>& points){ int number = points.size(); if (number < 3)return number; int res = 0; for (int i = 0; i < number - 1; i++) { int dup = 0; int Max = 0;//保存经过当前点的直线中,最多的点 unordered_map<string, int>m; for (int j = i + 1; j < number; j++) { int x = points[i][0] - points[j][0]; int y = points[i][1] - points[j][1]; if (x == 0 && y == 0) { dup++; continue; } if (x < 0) { x = -x; y = -y; } int i = gcd(x, y); x /= i; y /= i; string s = to_string(x); s = s + "@" + to_string(y); if (!m.count(s))m[s] = 1; else m[s]++; if (Max < m[s]) Max = m[s]; } res = max(res, Max + dup + 1); } return res; }