| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我彻底无语了!对这样的题目!#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<algorithm>
#define M 1000
#define eps 1e-8
#define INF 0xfffffff
using namespace std;
struct point
{
int x,y;
}po[M];
int n;
double xl[M*M];
double solve(point a,point b)
{
if(a.x!=b.x)
{return (a.y-b.y)*1.0/(a.x-b.x);}
else {return INF;}
}
int main()
{
int i,j,k;
int num,num1;
int maxn;
while(scanf("%d",&n)&&n)
{
for(i=0;i<n;i++)
scanf("%d%d",&po[i].x,&po[i].y);
maxn=-1;
for(i=0;i<n;i++)
{
k=0;num1=0;
for(j=i+1;j<n;j++)
{
double tmp=solve(po[i],po[j]);
if(fabs(tmp-INF*1.0)<eps)
num1++;//斜率不存在的情况
else xl[k++]=tmp;
}
sort(xl,xl+k);
num=1;
for(j=1;j<k;j++)
{
if(xl[j]-xl[j-1]<eps)
num++;
else num=1;
if(num>maxn)
maxn=num;
}
if( num1>maxn)
maxn=num1;
}
printf("%d\n",maxn+1);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator