题目链接:pku1118Lining Up 代码: // 1 < N < 700 #include <iostream> #include <cmath> #include <algorithm> using namespace std; const double eps=1e-10; const double INF=0xffffffff; struct point { long x,y; }; bool same (double x,double y) { return fabs(x-y)<eps ; } int main() { point p[705]; double slope[705]; int n,i,j,k; long s,max; while(cin>>n&&n) { for(i=0;i<n;i++) cin>>p[i].x>>p[i].y; max=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(p[j].x!=p[i].x) { slope[j]=1.0*(p[j].y-p[i].y)/(p[j].x-p[i].x); } else if(i==j)slope[j]=-INF; else { slope[j]=INF; } } sort(slope,slope+n); s=1; for(j=1;j<n;j++) if(same(slope[j],slope[j-1])) s++; else { if(max<s) max=s; s=1; } if(max<s) max=s; } printf("%ld/n",max+1); } return 0; }