题目大意:给定n个点,求一条直线最多能经过几个点(n<=1000)
做法:大暴力。。。枚举每一个点作为直线的端点,然后求出剩下n-1个点和它的斜率,斜率相同的说明可以同时在一条直线上
#include#define eps 1e-7#define N 500005using namespace std;int n,cnt;double tmp[N*10];struct Node{int x,y;}p[N];inline double getk(Node aa,Node bb){return 1.0*(aa.y-bb.y)/(double)(aa.x-bb.x);}int main(){ int cas=0; while (scanf("%d",&n)!=EOF){ if (n==0) return 0; cnt=0;cas++;int ans1=0; for (int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y); for (int i=1;i eps){ans=1;ans1=max(ans1,ans);continue;} else ans++,ans1=max(ans1,ans); } }ans1++; if (ans1<4) ans1=0; printf("Photo %d: %d points eliminated\n",cas,ans1); } return 0;}