[Description]: the two questions are about the number of points in a straight line.
[Analysis]: brute force and equal slope are used to solve the problem. However, when calculating the slope, division should be avoided, and all operations should be conducted by transposition multiplication. Otherwise, re will be performed.
Take "2606" as an example to paste code. "1118" only indicates that the array size is different, and the other values are the same.
// 216 K 0 Ms # include <iostream> using namespace STD; int A [205], B [205]; int main () {int t; CIN> T; int res; int ans = 0; For (INT I = 0; I <t; I ++) {CIN> A [I]> B [I];} for (INT I = 0; I <T-2; I ++) {for (Int J = I + 1; j <T-1; j ++) {res = 0; for (int K = J + 1; k <T; k ++) {If (B [J]-B [I]) * (a [k]-A [J]) = (a [J]-A [I]) * (B [k]-B [J]) res ++; If (RES> ans) ans = res ;}} cout <ans + 2 <Endl; return 0 ;}
Poj 1118 and 2606 (water question)