Enumerate all two points and add the third point to determine whether the three points are collocated.
Ga soeasy!
# Include <iostream> # include <cstring> # include <string> # include <cstdio> # include <cmath> # include <algorithm> # include <vector> # include <map> # define INF 0x3f3f3fusing namespace STD; struct point {int X, Y;} p [705]; bool CMP (point a, point B) {return. x <B. x;} int main () {int I, TMP, ANS, j, k, n, K1, K2, K3, K4; while (scanf ("% d ", & N) {for (I = 0; I <n; I ++) scanf ("% d", & P [I]. x, & P [I]. y); sort (p, p + N, CMP); ans = 1; // 1 for (I = 0; I <n; I ++) {for (j = I + 1; j <n; j ++) {TMP = 2; k1 = P [J]. x-P [I]. x; k2 = P [J]. y-P [I]. y; For (k = J + 1; k <n; k ++) {K3 = P [K]. x-P [J]. x; K4 = P [K]. y-P [J]. y; If (K1 * K4 = k2 * K3) {TMP ++; // printf ("% d \ n", I, j, k) ;}} if (TMP> ans) ans = TMP ;}} printf ("% d \ n", ANS) ;}return 0 ;}