比赛 20161114 评测结果 AAAAAAAAAA
题目名称 输出全靠花 最终得分 100
用户昵称 Satoshi 运行时间 1.202 s
代码语言 C++ 内存使用 0.33 MiB
提交时间 2016-11-14 12:30:29
显示代码纯文本
#include <fstream>
#include <map>
#define N 1010
#define K 4
using namespace std;
ifstream cin("xumingshi.in");
ofstream cout("xumingshi.out");
int ans=0,n;
class point
{
	public:
	int s[K];
    point(){for(int i=0;i<K;i++)s[i]=0;}
    void print()
    {
    	int i;
    	for(i=0;i<K;i++)cout<<s[i]<<' ';
    	cout<<endl;
    }
}P[N];
bool operator <(point a,point b)
{
	int i;
	for(i=0;i<K;i++)
	{
		if(a.s[i]==b.s[i])continue;
		return a.s[i]<b.s[i];
	}
	return 0;
}
point operator +(point a,point b)
{
	point c;
	for(int i=0;i<K;i++)c.s[i]=a.s[i]+b.s[i];
	return c;
}
point operator -(point a,point b)
{
	point c;
	for(int i=0;i<K;i++)c.s[i]=a.s[i]-b.s[i];
	return c;
}
point operator *(point a,int k)
{
	point c;
	for(int i=0;i<K;i++)c.s[i]=a.s[i]*k;
	return c;
}
point operator /(point a,int k)
{
	point c;
	for(int i=0;i<K;i++)c.s[i]=a.s[i]/k;
	return c;
}
int gcd(int x,int y)
{
	if(x<0)x=-x;
	if(y<0)y=-y;
	while(true)
	{
		if(!x)return y;
		if(!y)return x;
		if(x>y)x%=y;
		else y%=x;
	}
}
point decompose(point a)//约分,把向量化为最简 
{
	int i,d;
	for(i=0;i<K;i++)if(a.s[i])d=a.s[i];
	for(i=0;i<K;i++)if(a.s[i])d=gcd(d,a.s[i]);
	a=a/d;
	for(i=0;i<K;i++)
	{
		if(a.s[i]>0)break;
		if(a.s[i]<0)
		{
			a=a*(-1);
			break;
		}
	}
	return a;
}

void read()
{
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++)for(j=0;j<K;j++)cin>>P[i].s[j];
}
map<point,int> T;
void work()
{
	int i,j;
	point D;
	for(i=1;i<=n;i++)
	{
		T.clear();
		for(j=1;j<=n;j++)
		{
			if(i==j)continue;
			D=decompose(P[i]-P[j]);
			T[D]++;
			ans=max(ans,T[D]);
		}
	}
	cout<<ans+1<<endl;
}
int main()
{
	read();
	work();
	return 0;
}