poj 1118 Lining Up(水题)
2013-07-01 13:43
411 查看
再思考一下好的方法,水过,数据太弱! 本来不想传的!
#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;
}
#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;
}
相关文章推荐
- POJ 1118 Lining Up 水题一道
- POJ 1118 Lining Up(我的水题之路——斜率最多)
- poj 1118 Lining Up(水题)
- POJ1118 HDU1432 Lining Up【水题】
- poj 1118 Lining Up(暴力+数学)
- POJ 1118 Lining Up【几何】
- POJ 1118 Lining up 共线最大值
- poj 1118 Lining Up || poj 2780 Linearity || poj 2606 Rabbit hunt
- poj 1118 Lining Up 解题报告
- [POJ]1118 Lining up
- UVa 270 & POJ 1118 - Lining Up
- POJ 1118 Lining Up(枚举)
- POJ 1118 && HDU 1432 Lining Up(计算几何)
- poj 1118 Lining Up【同一条直线上的点】
- POJ 1118 Lining Up(点与直线)
- POJ 1118 Lining Up
- POJ 1118 Lining Up && POJ 2606 Rabbit hunt 找出一条直线上的点的最大个数
- poj1118Lining Up
- POJ 1118 Lining Up && POJ 2606 Rabbit hunt 找出一条直线上的点的最大个数
- uva 270 Lining Up/poj 1118