比赛 “Asm.Def战记之拉格朗日点”杯 评测结果 AAAAAAAWAA
题目名称 Asm.Def找燃料 最终得分 90
用户昵称 Collor 运行时间 0.015 s
代码语言 C++ 内存使用 0.28 MiB
提交时间 2015-11-04 11:50:51
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ctime>
using namespace std;
const int maxn=105;
struct node
{
	int x,y,v;
}a[maxn];
int n,f[maxn];
inline double Abs(double t){
	if (t<0)return -t;
	return t;
}
void init()
{
	memset(a,0,sizeof(a));
	cin>>n;
	int k=0;
	int xx,yy;
	for (int i=1;i<=n;) {
		
		scanf("%d%d",&xx,&yy);
		for (int j=1;j<i;j++) {
			if (a[j].x==xx&&a[j].y==yy){
				a[j].v++;

				goto Tail;
			}
		}
		a[++k].x=xx;
		a[k].y=yy;
		a[k].v++;
		Tail:
		i++;
	}
	n=k;
}
int main()
{
	freopen("asm_fuel.in","r",stdin);
	freopen("asm_fuel.out","w",stdout);
	//double t1 = (double)clock()/(double)CLOCKS_PER_SEC;
	
	init();
	
	int p;
	double p1,p2;
	//bool f1=0,f2=0;
	int sum=0,maxx=0;
	for (int i=1;i<n-1;i++){
		for (int j=i+1;j<n;j++) {
			sum = a[i].v+a[j].v;
			p=a[j].x-a[i].x;
			if (!p){
				for (int k=j+1;k<=n;k++)
					if (a[k].x==a[j].x)sum+=a[k].v;
				if (sum>maxx)maxx=sum;
				continue ; 
			}
			if (!(a[j].y-a[i].y)) {
				for (int k=j+1;k<=n;k++)
					if (a[k].y==a[j].y)sum+=a[k].v;
				if (sum>maxx)maxx=sum;
				continue ;
			}
			p1=((a[j].y-a[i].y)*1.000)/p;
			
			for (int k=j+1;k<=n;k++) {
				p2=((a[k].y-a[i].y)*1.000/(a[k].x-a[i].x));
				if (Abs(p2-p1)<0.001)sum+=a[k].v;
			}
			if (sum>maxx)maxx=sum;
		}
		
	}
	//double t2 = (double)clock()/(double)CLOCKS_PER_SEC;
	//printf("%lf\n",t2-t1);
	printf("%d\n",maxx);
	return 0;
}