poj 1118 Lining Up(水题)
再思考一下好的方法,水过,数据太弱! 本来不想传的!
#include <iostream> using namespace std; #define MAX 702 /*284K 422MS*/ typedef struct _point { int x; int y; }point; point p[MAX]; bool judge(point a,point b,point c) { return (a.y-b.y)*(c.x-b.x)-(c.y-b.y)*(a.x-b.x); } int main() { int n; while(cin>>n) { if(n==0) break; for(int i=0;i<n;i++) cin>>p[i].x>>p[i].y; int max=0; //暴力搜索 for(int k=0;k<n;k++) { for(int i=k+1;i<n;i++) { int sum=0; for(int j=i+1;j<n;j++) { if(!judge(p[k],p[i],p[j])) ++sum; } if(max<sum) max=sum; } } cout<<max+2<<endl; } system("pause"); return 0; }