比赛 20161114 评测结果 EEEEEAAEEE
题目名称 输出全靠花 最终得分 20
用户昵称 残星噬月 运行时间 0.580 s
代码语言 C++ 内存使用 1.81 MiB
提交时间 2016-11-14 10:44:58
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct sw
{
	int x;
	int y;
	int z;
	int w;
}s[1001];
int a[21][21][21][21];
int b[21][21][21][21];
int MAX=0;
void gcd(int x1,int y1,int z1,int w1)
{
	for(int i=2;i<=20;i++)
	{
		if(x1%i==0&&y1%i==0&&z1%i==0&&w1%i==0)
		{
			x1=x1/i;
			y1=y1/i;
			z1=z1/i;
			w1=w1/i;
		}
	}
}
int main()
{   freopen("xumingshi.in","r",stdin);
    freopen("xumingshi.out","w",stdout);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		
		cin>>s[i].x>>s[i].y>>s[i].z>>s[i].w;
		a[s[i].x][s[i].y][s[i].z][s[i].w]=1;
	}
	for(int i=0;i<n;i++)
	 for(int j=i+1;j<n;j++)
	 {  int ans=0;
	 	int x1=s[j].x-s[i].x;
	 	int y1=s[j].y-s[i].y;
	 	int z1=s[j].z-s[i].z;
	 	int w1=s[j].w-s[i].w;
		gcd(x1,y1,z1,w1);
		int x2=s[i].x;
		int y2=s[i].y;
		int z2=s[i].z;
		int w2=s[i].w;
		while(x2<21&&y2<21&&z2<21&&w2<21&&x2>=0&&y2>=0&&z2>=0&&w2>=0)
		{
			x2+=x1;
			y2+=y1;
			z2+=z1;
			w2+=w1;
			if(a[x2][y2][z2][w2]==1)ans+=1;
		 }
		  x2=s[i].x;
		  y2=s[i].y;
		  z2=s[i].z;
		  w2=s[i].w;
		while(x2<21&&y2<21&&w2<21&&z2<21&&x2>=0&&y2>=0&&z2>=0&&w2>=0)
		{
	      if(a[x2][y2][z2][w2]==1)ans+=1;
			x2-=x1;
			y2-=y1;
			z2-=z1;
			w2-=w1;
		
		  }  
		  MAX=max(ans,MAX);
		  }
		 cout<<MAX<<endl;
		 return 0;  
}